<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>IgH EtherCAT Master: device.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">IgH EtherCAT Master
   &#160;<span id="projectnumber">1.5.2</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',false,false,'search.php','Search');
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('device_8c_source.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">device.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="device_8c.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/******************************************************************************</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> *  $Id: device.c,v ec403cf308eb 2013/02/12 14:46:43 fp $</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> *  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> *  This file is part of the IgH EtherCAT Master.</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> *  The IgH EtherCAT Master is free software; you can redistribute it and/or</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> *  modify it under the terms of the GNU General Public License version 2, as</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> *  published by the Free Software Foundation.</span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment"> *  The IgH EtherCAT Master is distributed in the hope that it will be useful,</span></div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> *  but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General</span></div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> *  Public License for more details.</span></div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment"> *  You should have received a copy of the GNU General Public License along</span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment"> *  with the IgH EtherCAT Master; if not, write to the Free Software</span></div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment"> *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA</span></div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment"> *  ---</span></div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="comment"> *  The license mentioned above concerns the source code only. Using the</span></div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="comment"> *  EtherCAT technology and brand is only permitted in compliance with the</span></div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="comment"> *  industrial property and similar rights of Beckhoff Automation GmbH.</span></div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="comment"> *****************************************************************************/</span></div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="preprocessor">#include &lt;linux/module.h&gt;</span></div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="preprocessor">#include &lt;linux/skbuff.h&gt;</span></div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="preprocessor">#include &lt;linux/if_ether.h&gt;</span></div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="preprocessor">#include &lt;linux/netdevice.h&gt;</span></div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="device_8h.html">device.h</a>&quot;</span></div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="master_8h.html">master.h</a>&quot;</span></div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_RING</span></div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;<span class="preprocessor">#define timersub(a, b, result) \</span></div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;<span class="preprocessor">    do { \</span></div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;<span class="preprocessor">        (result)-&gt;tv_sec = (a)-&gt;tv_sec - (b)-&gt;tv_sec; \</span></div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;<span class="preprocessor">        (result)-&gt;tv_usec = (a)-&gt;tv_usec - (b)-&gt;tv_usec; \</span></div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;<span class="preprocessor">        if ((result)-&gt;tv_usec &lt; 0) { \</span></div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;<span class="preprocessor">            --(result)-&gt;tv_sec; \</span></div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;<span class="preprocessor">            (result)-&gt;tv_usec += 1000000; \</span></div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;<span class="preprocessor">        } \</span></div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;<span class="preprocessor">    } while (0)</span></div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;</div><div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="device_8h.html#a02288d2a8148ced6479c1285f9dc2bd1">   63</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="device_8c.html#a4984e3e354110c1f4694fd521491cc30">ec_device_init</a>(</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device, </div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;        <a class="code" href="structec__master.html">ec_master_t</a> *master </div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;        )</div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;{</div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <span class="keywordtype">int</span> ret;</div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    <span class="keyword">struct </span>ethhdr *eth;</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_IF</span></div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    <span class="keywordtype">char</span> ifname[10];</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    <span class="keywordtype">char</span> mb = <span class="charliteral">&#39;x&#39;</span>;</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a> = master;</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a> = NULL;</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    device-&gt;<a class="code" href="structec__device.html#aa51d769eb590a04e98f8544ea758322f">poll</a> = NULL;</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a79af9075672aa2abf993a703b4d964ed">module</a> = NULL;</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a0a3f5a12926e0d4ef17409d05b36d18a">open</a> = 0;</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    device-&gt;<a class="code" href="structec__device.html#ab58236227ed28e568e0de571499d5e68">link_state</a> = 0;</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code" href="device_8h.html#a8e81effb90ab4150ac1fe4114e7775f0">EC_TX_RING_SIZE</a>; i++) {</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a733aeb60035ac3696f05dc33adf49004">tx_skb</a>[i] = NULL;</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    }</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;    device-&gt;<a class="code" href="structec__device.html#af9353b63b910b0b64d06837b3f7075b7">tx_ring_index</a> = 0;</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;<span class="preprocessor">#ifdef EC_HAVE_CYCLES</span></div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;    device-&gt;cycles_poll = 0;</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_RING</span></div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    device-&gt;timeval_poll.tv_sec = 0;</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    device-&gt;timeval_poll.tv_usec = 0;</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    device-&gt;<a class="code" href="structec__device.html#af98c616a488455db59c5c4297206b8fb">jiffies_poll</a> = 0;</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;    <a class="code" href="device_8c.html#ac74ba2bebd2ed2468ec5b7942555ae9d">ec_device_clear_stats</a>(device);</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_RING</span></div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;    <span class="keywordflow">for</span> (i = 0; i &lt; EC_DEBUG_RING_SIZE; i++) {</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;        ec_debug_frame_t *df = &amp;device-&gt;debug_frames[i];</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;        df-&gt;dir = TX;</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;        df-&gt;t.tv_sec = 0;</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;        df-&gt;t.tv_usec = 0;</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;        memset(df-&gt;data, 0, <a class="code" href="globals_8h.html#a1e04c301942ee12b54c2caa25d3caab5">EC_MAX_DATA_SIZE</a>);</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;        df-&gt;data_size = 0;</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;    }</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_RING</span></div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    device-&gt;debug_frame_index = 0;</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;    device-&gt;debug_frame_count = 0;</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_IF</span></div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;    <span class="keywordflow">if</span> (device == &amp;master-&gt;<a class="code" href="structec__master.html#af339cc3b68bceb8ce25b02f4d8b5891b">devices</a>[<a class="code" href="globals_8h.html#ad1a2101422888687598d7e1a630c6343a6cc7c24499003f339df547ab73605f13">EC_DEVICE_MAIN</a>]) {</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;        mb = <span class="charliteral">&#39;m&#39;</span>;</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    }</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;    <span class="keywordflow">else</span> {</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;        mb = <span class="charliteral">&#39;b&#39;</span>;</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    }</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    sprintf(ifname, <span class="stringliteral">&quot;ecdbg%c%u&quot;</span>, mb, master-&gt;<a class="code" href="structec__master.html#a78fe13519ced082c9a212711bec49ed3">index</a>);</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    ret = <a class="code" href="debug_8c.html#ab4a40ce6bb6a66bd034790c3a7985c80">ec_debug_init</a>(&amp;device-&gt;dbg, device, ifname);</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    <span class="keywordflow">if</span> (ret &lt; 0) {</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;        <a class="code" href="master_8h.html#aece1fb7ea6af168ba7513c9d7b0a523a">EC_MASTER_ERR</a>(master, <span class="stringliteral">&quot;Failed to init debug device!\n&quot;</span>);</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;        <span class="keywordflow">goto</span> out_return;</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;    }</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code" href="device_8h.html#a8e81effb90ab4150ac1fe4114e7775f0">EC_TX_RING_SIZE</a>; i++) {</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;        <span class="keywordflow">if</span> (!(device-&gt;<a class="code" href="structec__device.html#a733aeb60035ac3696f05dc33adf49004">tx_skb</a>[i] = dev_alloc_skb(ETH_FRAME_LEN))) {</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;            <a class="code" href="master_8h.html#aece1fb7ea6af168ba7513c9d7b0a523a">EC_MASTER_ERR</a>(master, <span class="stringliteral">&quot;Error allocating device socket buffer!\n&quot;</span>);</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;            ret = -ENOMEM;</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;            <span class="keywordflow">goto</span> out_tx_ring;</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;        }</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;        <span class="comment">// add Ethernet-II-header</span></div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;        skb_reserve(device-&gt;<a class="code" href="structec__device.html#a733aeb60035ac3696f05dc33adf49004">tx_skb</a>[i], ETH_HLEN);</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;        eth = (<span class="keyword">struct </span>ethhdr *) skb_push(device-&gt;<a class="code" href="structec__device.html#a733aeb60035ac3696f05dc33adf49004">tx_skb</a>[i], ETH_HLEN);</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;        eth-&gt;h_proto = htons(0x88A4);</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;        memset(eth-&gt;h_dest, 0xFF, ETH_ALEN);</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    }</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;out_tx_ring:</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code" href="device_8h.html#a8e81effb90ab4150ac1fe4114e7775f0">EC_TX_RING_SIZE</a>; i++) {</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;        <span class="keywordflow">if</span> (device-&gt;<a class="code" href="structec__device.html#a733aeb60035ac3696f05dc33adf49004">tx_skb</a>[i]) {</div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;            dev_kfree_skb(device-&gt;<a class="code" href="structec__device.html#a733aeb60035ac3696f05dc33adf49004">tx_skb</a>[i]);</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;        }</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;    }</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_IF</span></div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;    <a class="code" href="debug_8c.html#a1711152b73dc97bc81a9e9aae4b8a263">ec_debug_clear</a>(&amp;device-&gt;dbg);</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;out_return:</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;    <span class="keywordflow">return</span> ret;</div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;}</div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;</div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;</div><div class="line"><a name="l00162"></a><span class="lineno"><a class="line" href="device_8h.html#a3099aa0e5bfa03897b85f4b542108d87">  162</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="device_8c.html#ad42f994e302efd7c59fc64bfc84f6037">ec_device_clear</a>(</div><div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device </div><div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;        )</div><div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;{</div><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;</div><div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;</div><div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;    <span class="keywordflow">if</span> (device-&gt;<a class="code" href="structec__device.html#a0a3f5a12926e0d4ef17409d05b36d18a">open</a>) {</div><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;        <a class="code" href="device_8c.html#a1d4eadd4b9da0e4298818434e1b78a9a">ec_device_close</a>(device);</div><div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;    }</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;    <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code" href="device_8h.html#a8e81effb90ab4150ac1fe4114e7775f0">EC_TX_RING_SIZE</a>; i++)</div><div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;        dev_kfree_skb(device-&gt;<a class="code" href="structec__device.html#a733aeb60035ac3696f05dc33adf49004">tx_skb</a>[i]);</div><div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_IF</span></div><div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;    <a class="code" href="debug_8c.html#a1711152b73dc97bc81a9e9aae4b8a263">ec_debug_clear</a>(&amp;device-&gt;dbg);</div><div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;}</div><div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;</div><div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;</div><div class="line"><a name="l00182"></a><span class="lineno"><a class="line" href="device_8h.html#a7f14ad3873acec6c4aab27a403b86e2f">  182</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="device_8c.html#a20976f86443d49ebf67caf83d4c0e156">ec_device_attach</a>(</div><div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device, </div><div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;        <span class="keyword">struct</span> net_device *net_dev, </div><div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;        <a class="code" href="ecdev_8h.html#a789bcd88d869f88c58bd13b451b3fd52">ec_pollfunc_t</a> poll, </div><div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;        <span class="keyword">struct</span> module *module </div><div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;        )</div><div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;{</div><div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;</div><div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;    <span class="keyword">struct </span>ethhdr *eth;</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;</div><div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;    <a class="code" href="device_8c.html#a12e63c43b18c206ba32fdb2a3d668bb8">ec_device_detach</a>(device); <span class="comment">// resets fields</span></div><div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;</div><div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a> = net_dev;</div><div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;    device-&gt;<a class="code" href="structec__device.html#aa51d769eb590a04e98f8544ea758322f">poll</a> = poll;</div><div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a79af9075672aa2abf993a703b4d964ed">module</a> = module;</div><div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;</div><div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;    <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code" href="device_8h.html#a8e81effb90ab4150ac1fe4114e7775f0">EC_TX_RING_SIZE</a>; i++) {</div><div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a733aeb60035ac3696f05dc33adf49004">tx_skb</a>[i]-&gt;dev = net_dev;</div><div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;        eth = (<span class="keyword">struct </span>ethhdr *) (device-&gt;<a class="code" href="structec__device.html#a733aeb60035ac3696f05dc33adf49004">tx_skb</a>[i]-&gt;data);</div><div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;        memcpy(eth-&gt;h_source, net_dev-&gt;dev_addr, ETH_ALEN);</div><div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;    }</div><div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;</div><div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_IF</span></div><div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;    <a class="code" href="debug_8c.html#a683a1dd06041ed934990c736ab3267a9">ec_debug_register</a>(&amp;device-&gt;dbg, net_dev);</div><div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;}</div><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;</div><div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;</div><div class="line"><a name="l00213"></a><span class="lineno"><a class="line" href="device_8h.html#a6aa86617de7ed991048e151847683a01">  213</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="device_8c.html#a12e63c43b18c206ba32fdb2a3d668bb8">ec_device_detach</a>(</div><div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device </div><div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;        )</div><div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;{</div><div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;</div><div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;</div><div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_IF</span></div><div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;    <a class="code" href="debug_8c.html#a488b3c97e9786a33f2372180de561591">ec_debug_unregister</a>(&amp;device-&gt;dbg);</div><div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;</div><div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a> = NULL;</div><div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;    device-&gt;<a class="code" href="structec__device.html#aa51d769eb590a04e98f8544ea758322f">poll</a> = NULL;</div><div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a79af9075672aa2abf993a703b4d964ed">module</a> = NULL;</div><div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a0a3f5a12926e0d4ef17409d05b36d18a">open</a> = 0;</div><div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;    device-&gt;<a class="code" href="structec__device.html#ab58236227ed28e568e0de571499d5e68">link_state</a> = 0; <span class="comment">// down</span></div><div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;</div><div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;    <a class="code" href="device_8c.html#ac74ba2bebd2ed2468ec5b7942555ae9d">ec_device_clear_stats</a>(device);</div><div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;</div><div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;    <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code" href="device_8h.html#a8e81effb90ab4150ac1fe4114e7775f0">EC_TX_RING_SIZE</a>; i++) {</div><div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a733aeb60035ac3696f05dc33adf49004">tx_skb</a>[i]-&gt;dev = NULL;</div><div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;    }</div><div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;}</div><div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;</div><div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;</div><div class="line"><a name="l00242"></a><span class="lineno"><a class="line" href="device_8h.html#abddc8be76e9422963c7814777bf80525">  242</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="device_8c.html#aec3d7ce9ab236b9626efefbc8c2ffd96">ec_device_open</a>(</div><div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device </div><div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;        )</div><div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;{</div><div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;    <span class="keywordtype">int</span> ret;</div><div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;</div><div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;    <span class="keywordflow">if</span> (!device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>) {</div><div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;        <a class="code" href="master_8h.html#aece1fb7ea6af168ba7513c9d7b0a523a">EC_MASTER_ERR</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>, <span class="stringliteral">&quot;No net_device to open!\n&quot;</span>);</div><div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;        <span class="keywordflow">return</span> -ENODEV;</div><div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;    }</div><div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;</div><div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;    <span class="keywordflow">if</span> (device-&gt;<a class="code" href="structec__device.html#a0a3f5a12926e0d4ef17409d05b36d18a">open</a>) {</div><div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;        <a class="code" href="master_8h.html#af75617c47fe87f4f60e8593d7e79dbc0">EC_MASTER_WARN</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>, <span class="stringliteral">&quot;Device already opened!\n&quot;</span>);</div><div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;        <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;    }</div><div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;</div><div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;    device-&gt;<a class="code" href="structec__device.html#ab58236227ed28e568e0de571499d5e68">link_state</a> = 0;</div><div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;</div><div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;    <a class="code" href="device_8c.html#ac74ba2bebd2ed2468ec5b7942555ae9d">ec_device_clear_stats</a>(device);</div><div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;</div><div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;<span class="preprocessor">#if LINUX_VERSION_CODE &gt;= KERNEL_VERSION(2, 6, 29)</span></div><div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;    ret = device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>-&gt;netdev_ops-&gt;ndo_open(device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>);</div><div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;<span class="preprocessor">#else</span></div><div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;    ret = device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>-&gt;open(device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>);</div><div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;    <span class="keywordflow">if</span> (!ret)</div><div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a0a3f5a12926e0d4ef17409d05b36d18a">open</a> = 1;</div><div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;</div><div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;    <span class="keywordflow">return</span> ret;</div><div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;}</div><div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;</div><div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;</div><div class="line"><a name="l00279"></a><span class="lineno"><a class="line" href="device_8h.html#afb0366cde94e727915b7bc0edd82e9d4">  279</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="device_8c.html#a1d4eadd4b9da0e4298818434e1b78a9a">ec_device_close</a>(</div><div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device </div><div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;        )</div><div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160;{</div><div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;    <span class="keywordtype">int</span> ret;</div><div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;</div><div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;    <span class="keywordflow">if</span> (!device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>) {</div><div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;        <a class="code" href="master_8h.html#aece1fb7ea6af168ba7513c9d7b0a523a">EC_MASTER_ERR</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>, <span class="stringliteral">&quot;No device to close!\n&quot;</span>);</div><div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;        <span class="keywordflow">return</span> -ENODEV;</div><div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;    }</div><div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;</div><div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;    <span class="keywordflow">if</span> (!device-&gt;<a class="code" href="structec__device.html#a0a3f5a12926e0d4ef17409d05b36d18a">open</a>) {</div><div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;        <a class="code" href="master_8h.html#af75617c47fe87f4f60e8593d7e79dbc0">EC_MASTER_WARN</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>, <span class="stringliteral">&quot;Device already closed!\n&quot;</span>);</div><div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;        <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;    }</div><div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;</div><div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;<span class="preprocessor">#if LINUX_VERSION_CODE &gt;= KERNEL_VERSION(2, 6, 29)</span></div><div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;    ret = device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>-&gt;netdev_ops-&gt;ndo_stop(device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>);</div><div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;<span class="preprocessor">#else</span></div><div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;    ret = device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>-&gt;stop(device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>);</div><div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;    <span class="keywordflow">if</span> (!ret)</div><div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a0a3f5a12926e0d4ef17409d05b36d18a">open</a> = 0;</div><div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;</div><div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;    <span class="keywordflow">return</span> ret;</div><div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;}</div><div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;</div><div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;</div><div class="line"><a name="l00312"></a><span class="lineno"><a class="line" href="device_8h.html#a5f9614c819d9e94aaea708f3351e2826">  312</a></span>&#160;uint8_t *<a class="code" href="device_8c.html#ac301d857a14ce98a79ffb12a7757bd09">ec_device_tx_data</a>(</div><div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device </div><div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;        )</div><div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;{</div><div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160;    <span class="comment">/* cycle through socket buffers, because otherwise there is a race</span></div><div class="line"><a name="l00317"></a><span class="lineno">  317</span>&#160;<span class="comment">     * condition, if multiple frames are sent and the DMA is not scheduled in</span></div><div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;<span class="comment">     * between. */</span></div><div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160;    device-&gt;<a class="code" href="structec__device.html#af9353b63b910b0b64d06837b3f7075b7">tx_ring_index</a>++;</div><div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;    device-&gt;<a class="code" href="structec__device.html#af9353b63b910b0b64d06837b3f7075b7">tx_ring_index</a> %= <a class="code" href="device_8h.html#a8e81effb90ab4150ac1fe4114e7775f0">EC_TX_RING_SIZE</a>;</div><div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;    <span class="keywordflow">return</span> device-&gt;<a class="code" href="structec__device.html#a733aeb60035ac3696f05dc33adf49004">tx_skb</a>[device-&gt;<a class="code" href="structec__device.html#af9353b63b910b0b64d06837b3f7075b7">tx_ring_index</a>]-&gt;data + ETH_HLEN;</div><div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;}</div><div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160;</div><div class="line"><a name="l00324"></a><span class="lineno">  324</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00325"></a><span class="lineno">  325</span>&#160;</div><div class="line"><a name="l00331"></a><span class="lineno"><a class="line" href="device_8h.html#acbce72d98a923245aca830dd82d2b36f">  331</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="device_8c.html#ad46f8a21db1dd635d52bbae01b3f467f">ec_device_send</a>(</div><div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device, </div><div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160;        <span class="keywordtype">size_t</span> size </div><div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;        )</div><div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;{</div><div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;    <span class="keyword">struct </span>sk_buff *skb = device-&gt;<a class="code" href="structec__device.html#a733aeb60035ac3696f05dc33adf49004">tx_skb</a>[device-&gt;<a class="code" href="structec__device.html#af9353b63b910b0b64d06837b3f7075b7">tx_ring_index</a>];</div><div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160;</div><div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160;    <span class="comment">// set the right length for the data</span></div><div class="line"><a name="l00339"></a><span class="lineno">  339</span>&#160;    skb-&gt;len = ETH_HLEN + size;</div><div class="line"><a name="l00340"></a><span class="lineno">  340</span>&#160;</div><div class="line"><a name="l00341"></a><span class="lineno">  341</span>&#160;    <span class="keywordflow">if</span> (unlikely(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>-&gt;<a class="code" href="structec__master.html#abdecf290f3f7f2af1b2a7bf0d9c7b08d">debug_level</a> &gt; 1)) {</div><div class="line"><a name="l00342"></a><span class="lineno">  342</span>&#160;        <a class="code" href="master_8h.html#a6cc0dea5aa374291f2379e844de741d0">EC_MASTER_DBG</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>, 2, <span class="stringliteral">&quot;Sending frame:\n&quot;</span>);</div><div class="line"><a name="l00343"></a><span class="lineno">  343</span>&#160;        <a class="code" href="globals_8h.html#af9b1cee5f8eb11448141bd02d52f44ac">ec_print_data</a>(skb-&gt;data, ETH_HLEN + size);</div><div class="line"><a name="l00344"></a><span class="lineno">  344</span>&#160;    }</div><div class="line"><a name="l00345"></a><span class="lineno">  345</span>&#160;</div><div class="line"><a name="l00346"></a><span class="lineno">  346</span>&#160;    <span class="comment">// start sending</span></div><div class="line"><a name="l00347"></a><span class="lineno">  347</span>&#160;<span class="preprocessor">#if LINUX_VERSION_CODE &gt;= KERNEL_VERSION(2, 6, 29)</span></div><div class="line"><a name="l00348"></a><span class="lineno">  348</span>&#160;    <span class="keywordflow">if</span> (device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>-&gt;netdev_ops-&gt;ndo_start_xmit(skb, device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>) ==</div><div class="line"><a name="l00349"></a><span class="lineno">  349</span>&#160;            NETDEV_TX_OK)</div><div class="line"><a name="l00350"></a><span class="lineno">  350</span>&#160;#<span class="keywordflow">else</span></div><div class="line"><a name="l00351"></a><span class="lineno">  351</span>&#160;    <span class="keywordflow">if</span> (device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>-&gt;hard_start_xmit(skb, device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>) == NETDEV_TX_OK)</div><div class="line"><a name="l00352"></a><span class="lineno">  352</span>&#160;#endif</div><div class="line"><a name="l00353"></a><span class="lineno">  353</span>&#160;    {</div><div class="line"><a name="l00354"></a><span class="lineno">  354</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a0cdf625147761dedcd8aa0ee08434949">tx_count</a>++;</div><div class="line"><a name="l00355"></a><span class="lineno">  355</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>-&gt;<a class="code" href="structec__master.html#a8109992ca98fdfc4d97610ec699fec31">device_stats</a>.<a class="code" href="structec__device__stats__t.html#a712dc5c0b9652b59fe8dfda4cd5cb0fe">tx_count</a>++;</div><div class="line"><a name="l00356"></a><span class="lineno">  356</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a969a3e6f0057eeb8b1becc34d500e281">tx_bytes</a> += ETH_HLEN + size;</div><div class="line"><a name="l00357"></a><span class="lineno">  357</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>-&gt;<a class="code" href="structec__master.html#a8109992ca98fdfc4d97610ec699fec31">device_stats</a>.<a class="code" href="structec__device__stats__t.html#ac4bcb52ad4f765671ffe124f4019b370">tx_bytes</a> += ETH_HLEN + size;</div><div class="line"><a name="l00358"></a><span class="lineno">  358</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_IF</span></div><div class="line"><a name="l00359"></a><span class="lineno">  359</span>&#160;        <a class="code" href="debug_8c.html#af11807b9c95c1c4f05aa0cd5a672a560">ec_debug_send</a>(&amp;device-&gt;dbg, skb-&gt;data, ETH_HLEN + size);</div><div class="line"><a name="l00360"></a><span class="lineno">  360</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00361"></a><span class="lineno">  361</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_RING</span></div><div class="line"><a name="l00362"></a><span class="lineno">  362</span>&#160;        ec_device_debug_ring_append(</div><div class="line"><a name="l00363"></a><span class="lineno">  363</span>&#160;                device, TX, skb-&gt;data + ETH_HLEN, size);</div><div class="line"><a name="l00364"></a><span class="lineno">  364</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00365"></a><span class="lineno">  365</span>&#160;    } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00366"></a><span class="lineno">  366</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a076ce4fd0d53e53ba7236b12bf4ecf66">tx_errors</a>++;</div><div class="line"><a name="l00367"></a><span class="lineno">  367</span>&#160;    }</div><div class="line"><a name="l00368"></a><span class="lineno">  368</span>&#160;}</div><div class="line"><a name="l00369"></a><span class="lineno">  369</span>&#160;</div><div class="line"><a name="l00370"></a><span class="lineno">  370</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00371"></a><span class="lineno">  371</span>&#160;</div><div class="line"><a name="l00374"></a><span class="lineno"><a class="line" href="device_8h.html#a2889ce889e3a481040666349d4220829">  374</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="device_8c.html#ac74ba2bebd2ed2468ec5b7942555ae9d">ec_device_clear_stats</a>(</div><div class="line"><a name="l00375"></a><span class="lineno">  375</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device </div><div class="line"><a name="l00376"></a><span class="lineno">  376</span>&#160;        )</div><div class="line"><a name="l00377"></a><span class="lineno">  377</span>&#160;{</div><div class="line"><a name="l00378"></a><span class="lineno">  378</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;</div><div class="line"><a name="l00379"></a><span class="lineno">  379</span>&#160;</div><div class="line"><a name="l00380"></a><span class="lineno">  380</span>&#160;    <span class="comment">// zero frame statistics</span></div><div class="line"><a name="l00381"></a><span class="lineno">  381</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a0cdf625147761dedcd8aa0ee08434949">tx_count</a> = 0;</div><div class="line"><a name="l00382"></a><span class="lineno">  382</span>&#160;    device-&gt;<a class="code" href="structec__device.html#afca221601cff7e6280283df48902a019">last_tx_count</a> = 0;</div><div class="line"><a name="l00383"></a><span class="lineno">  383</span>&#160;    device-&gt;<a class="code" href="structec__device.html#ab53eaa1db2b7696c28f06146fd253786">rx_count</a> = 0;</div><div class="line"><a name="l00384"></a><span class="lineno">  384</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a5ad25fde7d43696988dcb602fa947a7b">last_rx_count</a> = 0;</div><div class="line"><a name="l00385"></a><span class="lineno">  385</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a969a3e6f0057eeb8b1becc34d500e281">tx_bytes</a> = 0;</div><div class="line"><a name="l00386"></a><span class="lineno">  386</span>&#160;    device-&gt;<a class="code" href="structec__device.html#ac4a738c0943134edc5c68f2c85b9a089">last_tx_bytes</a> = 0;</div><div class="line"><a name="l00387"></a><span class="lineno">  387</span>&#160;    device-&gt;<a class="code" href="structec__device.html#afea25f45c6911c97a08b8615154a2b91">rx_bytes</a> = 0;</div><div class="line"><a name="l00388"></a><span class="lineno">  388</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a53f0337afe2d2bdb4b24e2ee4ccb8180">last_rx_bytes</a> = 0;</div><div class="line"><a name="l00389"></a><span class="lineno">  389</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a076ce4fd0d53e53ba7236b12bf4ecf66">tx_errors</a> = 0;</div><div class="line"><a name="l00390"></a><span class="lineno">  390</span>&#160;</div><div class="line"><a name="l00391"></a><span class="lineno">  391</span>&#160;    <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code" href="globals_8h.html#a00b477d166c2d09b9fea5d43c0c1cd48">EC_RATE_COUNT</a>; i++) {</div><div class="line"><a name="l00392"></a><span class="lineno">  392</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a0de91079b171a6b07cb724a6362f340b">tx_frame_rates</a>[i] = 0;</div><div class="line"><a name="l00393"></a><span class="lineno">  393</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a8e78783b1d22fd12b5d2abe263184bb1">rx_frame_rates</a>[i] = 0;</div><div class="line"><a name="l00394"></a><span class="lineno">  394</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a5decb734bd07c7e1a1b66e08904f0bba">tx_byte_rates</a>[i] = 0;</div><div class="line"><a name="l00395"></a><span class="lineno">  395</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a577e0651d974aa3db43fcb8fab639637">rx_byte_rates</a>[i] = 0;</div><div class="line"><a name="l00396"></a><span class="lineno">  396</span>&#160;    }</div><div class="line"><a name="l00397"></a><span class="lineno">  397</span>&#160;}</div><div class="line"><a name="l00398"></a><span class="lineno">  398</span>&#160;</div><div class="line"><a name="l00399"></a><span class="lineno">  399</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00400"></a><span class="lineno">  400</span>&#160;</div><div class="line"><a name="l00401"></a><span class="lineno">  401</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_RING</span></div><div class="line"><a name="l00402"></a><span class="lineno">  402</span>&#160;</div><div class="line"><a name="l00404"></a><span class="lineno">  404</span>&#160;<span class="keywordtype">void</span> ec_device_debug_ring_append(</div><div class="line"><a name="l00405"></a><span class="lineno">  405</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device, </div><div class="line"><a name="l00406"></a><span class="lineno">  406</span>&#160;        ec_debug_frame_dir_t dir, </div><div class="line"><a name="l00407"></a><span class="lineno">  407</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">void</span> *data, </div><div class="line"><a name="l00408"></a><span class="lineno">  408</span>&#160;        <span class="keywordtype">size_t</span> size </div><div class="line"><a name="l00409"></a><span class="lineno">  409</span>&#160;        )</div><div class="line"><a name="l00410"></a><span class="lineno">  410</span>&#160;{</div><div class="line"><a name="l00411"></a><span class="lineno">  411</span>&#160;    ec_debug_frame_t *df = &amp;device-&gt;debug_frames[device-&gt;debug_frame_index];</div><div class="line"><a name="l00412"></a><span class="lineno">  412</span>&#160;</div><div class="line"><a name="l00413"></a><span class="lineno">  413</span>&#160;    df-&gt;dir = dir;</div><div class="line"><a name="l00414"></a><span class="lineno">  414</span>&#160;    <span class="keywordflow">if</span> (dir == TX) {</div><div class="line"><a name="l00415"></a><span class="lineno">  415</span>&#160;        do_gettimeofday(&amp;df-&gt;t);</div><div class="line"><a name="l00416"></a><span class="lineno">  416</span>&#160;    }</div><div class="line"><a name="l00417"></a><span class="lineno">  417</span>&#160;    <span class="keywordflow">else</span> {</div><div class="line"><a name="l00418"></a><span class="lineno">  418</span>&#160;        df-&gt;t = device-&gt;timeval_poll;</div><div class="line"><a name="l00419"></a><span class="lineno">  419</span>&#160;    }</div><div class="line"><a name="l00420"></a><span class="lineno">  420</span>&#160;    memcpy(df-&gt;data, data, size);</div><div class="line"><a name="l00421"></a><span class="lineno">  421</span>&#160;    df-&gt;data_size = size;</div><div class="line"><a name="l00422"></a><span class="lineno">  422</span>&#160;</div><div class="line"><a name="l00423"></a><span class="lineno">  423</span>&#160;    device-&gt;debug_frame_index++;</div><div class="line"><a name="l00424"></a><span class="lineno">  424</span>&#160;    device-&gt;debug_frame_index %= EC_DEBUG_RING_SIZE;</div><div class="line"><a name="l00425"></a><span class="lineno">  425</span>&#160;    <span class="keywordflow">if</span> (unlikely(device-&gt;debug_frame_count &lt; EC_DEBUG_RING_SIZE))</div><div class="line"><a name="l00426"></a><span class="lineno">  426</span>&#160;        device-&gt;debug_frame_count++;</div><div class="line"><a name="l00427"></a><span class="lineno">  427</span>&#160;}</div><div class="line"><a name="l00428"></a><span class="lineno">  428</span>&#160;</div><div class="line"><a name="l00429"></a><span class="lineno">  429</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00430"></a><span class="lineno">  430</span>&#160;</div><div class="line"><a name="l00433"></a><span class="lineno">  433</span>&#160;<span class="keywordtype">void</span> ec_device_debug_ring_print(</div><div class="line"><a name="l00434"></a><span class="lineno">  434</span>&#160;        <span class="keyword">const</span> <a class="code" href="structec__device.html">ec_device_t</a> *device </div><div class="line"><a name="l00435"></a><span class="lineno">  435</span>&#160;        )</div><div class="line"><a name="l00436"></a><span class="lineno">  436</span>&#160;{</div><div class="line"><a name="l00437"></a><span class="lineno">  437</span>&#160;    <span class="keywordtype">int</span> i;</div><div class="line"><a name="l00438"></a><span class="lineno">  438</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> ring_index;</div><div class="line"><a name="l00439"></a><span class="lineno">  439</span>&#160;    <span class="keyword">const</span> ec_debug_frame_t *df;</div><div class="line"><a name="l00440"></a><span class="lineno">  440</span>&#160;    <span class="keyword">struct </span>timeval t0, diff;</div><div class="line"><a name="l00441"></a><span class="lineno">  441</span>&#160;</div><div class="line"><a name="l00442"></a><span class="lineno">  442</span>&#160;    <span class="comment">// calculate index of the newest frame in the ring to get its time</span></div><div class="line"><a name="l00443"></a><span class="lineno">  443</span>&#160;    ring_index = (device-&gt;debug_frame_index + EC_DEBUG_RING_SIZE - 1)</div><div class="line"><a name="l00444"></a><span class="lineno">  444</span>&#160;        % EC_DEBUG_RING_SIZE;</div><div class="line"><a name="l00445"></a><span class="lineno">  445</span>&#160;    t0 = device-&gt;debug_frames[ring_index].t;</div><div class="line"><a name="l00446"></a><span class="lineno">  446</span>&#160;</div><div class="line"><a name="l00447"></a><span class="lineno">  447</span>&#160;    <a class="code" href="master_8h.html#a6cc0dea5aa374291f2379e844de741d0">EC_MASTER_DBG</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>, 1, <span class="stringliteral">&quot;Debug ring %u:\n&quot;</span>, ring_index);</div><div class="line"><a name="l00448"></a><span class="lineno">  448</span>&#160;</div><div class="line"><a name="l00449"></a><span class="lineno">  449</span>&#160;    <span class="comment">// calculate index of the oldest frame in the ring</span></div><div class="line"><a name="l00450"></a><span class="lineno">  450</span>&#160;    ring_index = (device-&gt;debug_frame_index + EC_DEBUG_RING_SIZE</div><div class="line"><a name="l00451"></a><span class="lineno">  451</span>&#160;            - device-&gt;debug_frame_count) % EC_DEBUG_RING_SIZE;</div><div class="line"><a name="l00452"></a><span class="lineno">  452</span>&#160;</div><div class="line"><a name="l00453"></a><span class="lineno">  453</span>&#160;    <span class="keywordflow">for</span> (i = 0; i &lt; device-&gt;debug_frame_count; i++) {</div><div class="line"><a name="l00454"></a><span class="lineno">  454</span>&#160;        df = &amp;device-&gt;debug_frames[ring_index];</div><div class="line"><a name="l00455"></a><span class="lineno">  455</span>&#160;        timersub(&amp;t0, &amp;df-&gt;t, &amp;diff);</div><div class="line"><a name="l00456"></a><span class="lineno">  456</span>&#160;</div><div class="line"><a name="l00457"></a><span class="lineno">  457</span>&#160;        <a class="code" href="master_8h.html#a6cc0dea5aa374291f2379e844de741d0">EC_MASTER_DBG</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>, 1, <span class="stringliteral">&quot;Frame %u, dt=%u.%06u s, %s:\n&quot;</span>,</div><div class="line"><a name="l00458"></a><span class="lineno">  458</span>&#160;                i + 1 - device-&gt;debug_frame_count,</div><div class="line"><a name="l00459"></a><span class="lineno">  459</span>&#160;                (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>) diff.tv_sec,</div><div class="line"><a name="l00460"></a><span class="lineno">  460</span>&#160;                (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>) diff.tv_usec,</div><div class="line"><a name="l00461"></a><span class="lineno">  461</span>&#160;                (df-&gt;dir == TX) ? <span class="stringliteral">&quot;TX&quot;</span> : <span class="stringliteral">&quot;RX&quot;</span>);</div><div class="line"><a name="l00462"></a><span class="lineno">  462</span>&#160;        <a class="code" href="globals_8h.html#af9b1cee5f8eb11448141bd02d52f44ac">ec_print_data</a>(df-&gt;data, df-&gt;data_size);</div><div class="line"><a name="l00463"></a><span class="lineno">  463</span>&#160;</div><div class="line"><a name="l00464"></a><span class="lineno">  464</span>&#160;        ring_index++;</div><div class="line"><a name="l00465"></a><span class="lineno">  465</span>&#160;        ring_index %= EC_DEBUG_RING_SIZE;</div><div class="line"><a name="l00466"></a><span class="lineno">  466</span>&#160;    }</div><div class="line"><a name="l00467"></a><span class="lineno">  467</span>&#160;}</div><div class="line"><a name="l00468"></a><span class="lineno">  468</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00469"></a><span class="lineno">  469</span>&#160;</div><div class="line"><a name="l00470"></a><span class="lineno">  470</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00471"></a><span class="lineno">  471</span>&#160;</div><div class="line"><a name="l00478"></a><span class="lineno"><a class="line" href="device_8h.html#ae9ba13e6b8f14f6633250f176e82bec2">  478</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="device_8c.html#a6944619b6e1c0f85d5f7d124a0a71af2">ec_device_poll</a>(</div><div class="line"><a name="l00479"></a><span class="lineno">  479</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device </div><div class="line"><a name="l00480"></a><span class="lineno">  480</span>&#160;        )</div><div class="line"><a name="l00481"></a><span class="lineno">  481</span>&#160;{</div><div class="line"><a name="l00482"></a><span class="lineno">  482</span>&#160;<span class="preprocessor">#ifdef EC_HAVE_CYCLES</span></div><div class="line"><a name="l00483"></a><span class="lineno">  483</span>&#160;    device-&gt;cycles_poll = get_cycles();</div><div class="line"><a name="l00484"></a><span class="lineno">  484</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00485"></a><span class="lineno">  485</span>&#160;    device-&gt;<a class="code" href="structec__device.html#af98c616a488455db59c5c4297206b8fb">jiffies_poll</a> = jiffies;</div><div class="line"><a name="l00486"></a><span class="lineno">  486</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_RING</span></div><div class="line"><a name="l00487"></a><span class="lineno">  487</span>&#160;    do_gettimeofday(&amp;device-&gt;timeval_poll);</div><div class="line"><a name="l00488"></a><span class="lineno">  488</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00489"></a><span class="lineno">  489</span>&#160;    device-&gt;<a class="code" href="structec__device.html#aa51d769eb590a04e98f8544ea758322f">poll</a>(device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>);</div><div class="line"><a name="l00490"></a><span class="lineno">  490</span>&#160;}</div><div class="line"><a name="l00491"></a><span class="lineno">  491</span>&#160;</div><div class="line"><a name="l00492"></a><span class="lineno">  492</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00493"></a><span class="lineno">  493</span>&#160;</div><div class="line"><a name="l00496"></a><span class="lineno"><a class="line" href="device_8h.html#a487e82c3004aafd09d2a2b993960ee60">  496</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="device_8c.html#a158275fbb94b82be5d551044f38981f4">ec_device_update_stats</a>(</div><div class="line"><a name="l00497"></a><span class="lineno">  497</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device </div><div class="line"><a name="l00498"></a><span class="lineno">  498</span>&#160;        )</div><div class="line"><a name="l00499"></a><span class="lineno">  499</span>&#160;{</div><div class="line"><a name="l00500"></a><span class="lineno">  500</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;</div><div class="line"><a name="l00501"></a><span class="lineno">  501</span>&#160;</div><div class="line"><a name="l00502"></a><span class="lineno">  502</span>&#160;    s32 tx_frame_rate = (device-&gt;<a class="code" href="structec__device.html#a0cdf625147761dedcd8aa0ee08434949">tx_count</a> - device-&gt;<a class="code" href="structec__device.html#afca221601cff7e6280283df48902a019">last_tx_count</a>) * 1000;</div><div class="line"><a name="l00503"></a><span class="lineno">  503</span>&#160;    s32 rx_frame_rate = (device-&gt;<a class="code" href="structec__device.html#ab53eaa1db2b7696c28f06146fd253786">rx_count</a> - device-&gt;<a class="code" href="structec__device.html#a5ad25fde7d43696988dcb602fa947a7b">last_rx_count</a>) * 1000;</div><div class="line"><a name="l00504"></a><span class="lineno">  504</span>&#160;    s32 tx_byte_rate = (device-&gt;<a class="code" href="structec__device.html#a969a3e6f0057eeb8b1becc34d500e281">tx_bytes</a> - device-&gt;<a class="code" href="structec__device.html#ac4a738c0943134edc5c68f2c85b9a089">last_tx_bytes</a>);</div><div class="line"><a name="l00505"></a><span class="lineno">  505</span>&#160;    s32 rx_byte_rate = (device-&gt;<a class="code" href="structec__device.html#afea25f45c6911c97a08b8615154a2b91">rx_bytes</a> - device-&gt;<a class="code" href="structec__device.html#a53f0337afe2d2bdb4b24e2ee4ccb8180">last_rx_bytes</a>);</div><div class="line"><a name="l00506"></a><span class="lineno">  506</span>&#160;</div><div class="line"><a name="l00507"></a><span class="lineno">  507</span>&#160;    <span class="comment">/* Low-pass filter:</span></div><div class="line"><a name="l00508"></a><span class="lineno">  508</span>&#160;<span class="comment">     *      Y_n = y_(n - 1) + T / tau * (x - y_(n - 1))   | T = 1</span></div><div class="line"><a name="l00509"></a><span class="lineno">  509</span>&#160;<span class="comment">     *   -&gt; Y_n += (x - y_(n - 1)) / tau</span></div><div class="line"><a name="l00510"></a><span class="lineno">  510</span>&#160;<span class="comment">     */</span></div><div class="line"><a name="l00511"></a><span class="lineno">  511</span>&#160;    <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code" href="globals_8h.html#a00b477d166c2d09b9fea5d43c0c1cd48">EC_RATE_COUNT</a>; i++) {</div><div class="line"><a name="l00512"></a><span class="lineno">  512</span>&#160;        s32 n = <a class="code" href="master_8c.html#a07848f103b98208d90a6fec920790500">rate_intervals</a>[i];</div><div class="line"><a name="l00513"></a><span class="lineno">  513</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a0de91079b171a6b07cb724a6362f340b">tx_frame_rates</a>[i] +=</div><div class="line"><a name="l00514"></a><span class="lineno">  514</span>&#160;            (tx_frame_rate - device-&gt;<a class="code" href="structec__device.html#a0de91079b171a6b07cb724a6362f340b">tx_frame_rates</a>[i]) / n;</div><div class="line"><a name="l00515"></a><span class="lineno">  515</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a8e78783b1d22fd12b5d2abe263184bb1">rx_frame_rates</a>[i] +=</div><div class="line"><a name="l00516"></a><span class="lineno">  516</span>&#160;            (rx_frame_rate - device-&gt;<a class="code" href="structec__device.html#a8e78783b1d22fd12b5d2abe263184bb1">rx_frame_rates</a>[i]) / n;</div><div class="line"><a name="l00517"></a><span class="lineno">  517</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a5decb734bd07c7e1a1b66e08904f0bba">tx_byte_rates</a>[i] +=</div><div class="line"><a name="l00518"></a><span class="lineno">  518</span>&#160;            (tx_byte_rate - device-&gt;<a class="code" href="structec__device.html#a5decb734bd07c7e1a1b66e08904f0bba">tx_byte_rates</a>[i]) / n;</div><div class="line"><a name="l00519"></a><span class="lineno">  519</span>&#160;        device-&gt;<a class="code" href="structec__device.html#a577e0651d974aa3db43fcb8fab639637">rx_byte_rates</a>[i] +=</div><div class="line"><a name="l00520"></a><span class="lineno">  520</span>&#160;            (rx_byte_rate - device-&gt;<a class="code" href="structec__device.html#a577e0651d974aa3db43fcb8fab639637">rx_byte_rates</a>[i]) / n;</div><div class="line"><a name="l00521"></a><span class="lineno">  521</span>&#160;    }</div><div class="line"><a name="l00522"></a><span class="lineno">  522</span>&#160;</div><div class="line"><a name="l00523"></a><span class="lineno">  523</span>&#160;    device-&gt;<a class="code" href="structec__device.html#afca221601cff7e6280283df48902a019">last_tx_count</a> = device-&gt;<a class="code" href="structec__device.html#a0cdf625147761dedcd8aa0ee08434949">tx_count</a>;</div><div class="line"><a name="l00524"></a><span class="lineno">  524</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a5ad25fde7d43696988dcb602fa947a7b">last_rx_count</a> = device-&gt;<a class="code" href="structec__device.html#ab53eaa1db2b7696c28f06146fd253786">rx_count</a>;</div><div class="line"><a name="l00525"></a><span class="lineno">  525</span>&#160;    device-&gt;<a class="code" href="structec__device.html#ac4a738c0943134edc5c68f2c85b9a089">last_tx_bytes</a> = device-&gt;<a class="code" href="structec__device.html#a969a3e6f0057eeb8b1becc34d500e281">tx_bytes</a>;</div><div class="line"><a name="l00526"></a><span class="lineno">  526</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a53f0337afe2d2bdb4b24e2ee4ccb8180">last_rx_bytes</a> = device-&gt;<a class="code" href="structec__device.html#afea25f45c6911c97a08b8615154a2b91">rx_bytes</a>;</div><div class="line"><a name="l00527"></a><span class="lineno">  527</span>&#160;}</div><div class="line"><a name="l00528"></a><span class="lineno">  528</span>&#160;</div><div class="line"><a name="l00529"></a><span class="lineno">  529</span>&#160;<span class="comment">/******************************************************************************</span></div><div class="line"><a name="l00530"></a><span class="lineno">  530</span>&#160;<span class="comment"> *  Device interface</span></div><div class="line"><a name="l00531"></a><span class="lineno">  531</span>&#160;<span class="comment"> *****************************************************************************/</span></div><div class="line"><a name="l00532"></a><span class="lineno">  532</span>&#160;</div><div class="line"><a name="l00543"></a><span class="lineno"><a class="line" href="group__DeviceInterface.html#ga3934f8a07aa394d558147d790fc60a8b">  543</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="group__DeviceInterface.html#ga3934f8a07aa394d558147d790fc60a8b">ecdev_withdraw</a>(<a class="code" href="structec__device.html">ec_device_t</a> *device )</div><div class="line"><a name="l00544"></a><span class="lineno">  544</span>&#160;{</div><div class="line"><a name="l00545"></a><span class="lineno">  545</span>&#160;    <a class="code" href="structec__master.html">ec_master_t</a> *master = device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>;</div><div class="line"><a name="l00546"></a><span class="lineno">  546</span>&#160;    <span class="keywordtype">char</span> dev_str[20], mac_str[20];</div><div class="line"><a name="l00547"></a><span class="lineno">  547</span>&#160;</div><div class="line"><a name="l00548"></a><span class="lineno">  548</span>&#160;    <a class="code" href="globals_8h.html#a494695f2cebf0403348cb6281e0af0c9">ec_mac_print</a>(device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>-&gt;dev_addr, mac_str);</div><div class="line"><a name="l00549"></a><span class="lineno">  549</span>&#160;</div><div class="line"><a name="l00550"></a><span class="lineno">  550</span>&#160;    <span class="keywordflow">if</span> (device == &amp;master-&gt;<a class="code" href="structec__master.html#af339cc3b68bceb8ce25b02f4d8b5891b">devices</a>[<a class="code" href="globals_8h.html#ad1a2101422888687598d7e1a630c6343a6cc7c24499003f339df547ab73605f13">EC_DEVICE_MAIN</a>]) {</div><div class="line"><a name="l00551"></a><span class="lineno">  551</span>&#160;        sprintf(dev_str, <span class="stringliteral">&quot;main&quot;</span>);</div><div class="line"><a name="l00552"></a><span class="lineno">  552</span>&#160;    } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (device == &amp;master-&gt;<a class="code" href="structec__master.html#af339cc3b68bceb8ce25b02f4d8b5891b">devices</a>[<a class="code" href="globals_8h.html#ad1a2101422888687598d7e1a630c6343ab269739586dbb817c1e0ff42e74c5111">EC_DEVICE_BACKUP</a>]) {</div><div class="line"><a name="l00553"></a><span class="lineno">  553</span>&#160;        sprintf(dev_str, <span class="stringliteral">&quot;backup&quot;</span>);</div><div class="line"><a name="l00554"></a><span class="lineno">  554</span>&#160;    } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00555"></a><span class="lineno">  555</span>&#160;        <a class="code" href="master_8h.html#af75617c47fe87f4f60e8593d7e79dbc0">EC_MASTER_WARN</a>(master, <span class="stringliteral">&quot;%s() called with unknown device %s!\n&quot;</span>,</div><div class="line"><a name="l00556"></a><span class="lineno">  556</span>&#160;                __func__, mac_str);</div><div class="line"><a name="l00557"></a><span class="lineno">  557</span>&#160;        sprintf(dev_str, <span class="stringliteral">&quot;UNKNOWN&quot;</span>);</div><div class="line"><a name="l00558"></a><span class="lineno">  558</span>&#160;    }</div><div class="line"><a name="l00559"></a><span class="lineno">  559</span>&#160;</div><div class="line"><a name="l00560"></a><span class="lineno">  560</span>&#160;    <a class="code" href="master_8h.html#a306a2bcfad973302ae507c9c6978b816">EC_MASTER_INFO</a>(master, <span class="stringliteral">&quot;Releasing %s device %s.\n&quot;</span>, dev_str, mac_str);</div><div class="line"><a name="l00561"></a><span class="lineno">  561</span>&#160;</div><div class="line"><a name="l00562"></a><span class="lineno">  562</span>&#160;    down(&amp;master-&gt;<a class="code" href="structec__master.html#acbd28a1ea76d9b758e53a987b18a59c7">device_sem</a>);</div><div class="line"><a name="l00563"></a><span class="lineno">  563</span>&#160;    <a class="code" href="device_8c.html#a12e63c43b18c206ba32fdb2a3d668bb8">ec_device_detach</a>(device);</div><div class="line"><a name="l00564"></a><span class="lineno">  564</span>&#160;    up(&amp;master-&gt;<a class="code" href="structec__master.html#acbd28a1ea76d9b758e53a987b18a59c7">device_sem</a>);</div><div class="line"><a name="l00565"></a><span class="lineno">  565</span>&#160;}</div><div class="line"><a name="l00566"></a><span class="lineno">  566</span>&#160;</div><div class="line"><a name="l00567"></a><span class="lineno">  567</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00568"></a><span class="lineno">  568</span>&#160;</div><div class="line"><a name="l00574"></a><span class="lineno"><a class="line" href="group__DeviceInterface.html#ga34eceaecfe6ab4fe8f0ecde1a3b311c4">  574</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="group__DeviceInterface.html#ga34eceaecfe6ab4fe8f0ecde1a3b311c4">ecdev_open</a>(<a class="code" href="structec__device.html">ec_device_t</a> *device )</div><div class="line"><a name="l00575"></a><span class="lineno">  575</span>&#160;{</div><div class="line"><a name="l00576"></a><span class="lineno">  576</span>&#160;    <span class="keywordtype">int</span> ret;</div><div class="line"><a name="l00577"></a><span class="lineno">  577</span>&#160;    <a class="code" href="structec__master.html">ec_master_t</a> *master = device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>;</div><div class="line"><a name="l00578"></a><span class="lineno">  578</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> all_open = 1, dev_idx;</div><div class="line"><a name="l00579"></a><span class="lineno">  579</span>&#160;</div><div class="line"><a name="l00580"></a><span class="lineno">  580</span>&#160;    ret = <a class="code" href="device_8c.html#aec3d7ce9ab236b9626efefbc8c2ffd96">ec_device_open</a>(device);</div><div class="line"><a name="l00581"></a><span class="lineno">  581</span>&#160;    <span class="keywordflow">if</span> (ret) {</div><div class="line"><a name="l00582"></a><span class="lineno">  582</span>&#160;        <a class="code" href="master_8h.html#aece1fb7ea6af168ba7513c9d7b0a523a">EC_MASTER_ERR</a>(master, <span class="stringliteral">&quot;Failed to open device!\n&quot;</span>);</div><div class="line"><a name="l00583"></a><span class="lineno">  583</span>&#160;        <span class="keywordflow">return</span> ret;</div><div class="line"><a name="l00584"></a><span class="lineno">  584</span>&#160;    }</div><div class="line"><a name="l00585"></a><span class="lineno">  585</span>&#160;</div><div class="line"><a name="l00586"></a><span class="lineno">  586</span>&#160;    <span class="keywordflow">for</span> (dev_idx = <a class="code" href="globals_8h.html#ad1a2101422888687598d7e1a630c6343a6cc7c24499003f339df547ab73605f13">EC_DEVICE_MAIN</a>;</div><div class="line"><a name="l00587"></a><span class="lineno">  587</span>&#160;            dev_idx &lt; <a class="code" href="master_8h.html#a27e6deff35543c304e8a191c64f35cf3">ec_master_num_devices</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>); dev_idx++) {</div><div class="line"><a name="l00588"></a><span class="lineno">  588</span>&#160;        <span class="keywordflow">if</span> (!master-&gt;<a class="code" href="structec__master.html#af339cc3b68bceb8ce25b02f4d8b5891b">devices</a>[dev_idx].<a class="code" href="structec__device.html#a0a3f5a12926e0d4ef17409d05b36d18a">open</a>) {</div><div class="line"><a name="l00589"></a><span class="lineno">  589</span>&#160;            all_open = 0;</div><div class="line"><a name="l00590"></a><span class="lineno">  590</span>&#160;            <span class="keywordflow">break</span>;</div><div class="line"><a name="l00591"></a><span class="lineno">  591</span>&#160;        }</div><div class="line"><a name="l00592"></a><span class="lineno">  592</span>&#160;    }</div><div class="line"><a name="l00593"></a><span class="lineno">  593</span>&#160;</div><div class="line"><a name="l00594"></a><span class="lineno">  594</span>&#160;    <span class="keywordflow">if</span> (all_open) {</div><div class="line"><a name="l00595"></a><span class="lineno">  595</span>&#160;        ret = <a class="code" href="master_8c.html#a953107732b8b44631afcb3d2f82964a0">ec_master_enter_idle_phase</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>);</div><div class="line"><a name="l00596"></a><span class="lineno">  596</span>&#160;        <span class="keywordflow">if</span> (ret) {</div><div class="line"><a name="l00597"></a><span class="lineno">  597</span>&#160;            <a class="code" href="master_8h.html#aece1fb7ea6af168ba7513c9d7b0a523a">EC_MASTER_ERR</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>, <span class="stringliteral">&quot;Failed to enter IDLE phase!\n&quot;</span>);</div><div class="line"><a name="l00598"></a><span class="lineno">  598</span>&#160;            <span class="keywordflow">return</span> ret;</div><div class="line"><a name="l00599"></a><span class="lineno">  599</span>&#160;        }</div><div class="line"><a name="l00600"></a><span class="lineno">  600</span>&#160;    }</div><div class="line"><a name="l00601"></a><span class="lineno">  601</span>&#160;</div><div class="line"><a name="l00602"></a><span class="lineno">  602</span>&#160;    <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00603"></a><span class="lineno">  603</span>&#160;}</div><div class="line"><a name="l00604"></a><span class="lineno">  604</span>&#160;</div><div class="line"><a name="l00605"></a><span class="lineno">  605</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00606"></a><span class="lineno">  606</span>&#160;</div><div class="line"><a name="l00612"></a><span class="lineno"><a class="line" href="group__DeviceInterface.html#ga0a6b26b2397aa49cc82915a12b8cc854">  612</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="group__DeviceInterface.html#ga0a6b26b2397aa49cc82915a12b8cc854">ecdev_close</a>(<a class="code" href="structec__device.html">ec_device_t</a> *device )</div><div class="line"><a name="l00613"></a><span class="lineno">  613</span>&#160;{</div><div class="line"><a name="l00614"></a><span class="lineno">  614</span>&#160;    <a class="code" href="structec__master.html">ec_master_t</a> *master = device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>;</div><div class="line"><a name="l00615"></a><span class="lineno">  615</span>&#160;</div><div class="line"><a name="l00616"></a><span class="lineno">  616</span>&#160;    <span class="keywordflow">if</span> (master-&gt;<a class="code" href="structec__master.html#aeeac95bdfc711903f48710b31e8b78a2">phase</a> == <a class="code" href="master_8h.html#aebcf0998049ecde580a47832fb3b36f0a243c4f44013cdfedb1105cb13e6b1191">EC_IDLE</a>) {</div><div class="line"><a name="l00617"></a><span class="lineno">  617</span>&#160;        <a class="code" href="master_8c.html#a064c1933a370bf502e0bf42e15ae45f9">ec_master_leave_idle_phase</a>(master);</div><div class="line"><a name="l00618"></a><span class="lineno">  618</span>&#160;    }</div><div class="line"><a name="l00619"></a><span class="lineno">  619</span>&#160;</div><div class="line"><a name="l00620"></a><span class="lineno">  620</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="device_8c.html#a1d4eadd4b9da0e4298818434e1b78a9a">ec_device_close</a>(device)) {</div><div class="line"><a name="l00621"></a><span class="lineno">  621</span>&#160;        <a class="code" href="master_8h.html#af75617c47fe87f4f60e8593d7e79dbc0">EC_MASTER_WARN</a>(master, <span class="stringliteral">&quot;Failed to close device!\n&quot;</span>);</div><div class="line"><a name="l00622"></a><span class="lineno">  622</span>&#160;    }</div><div class="line"><a name="l00623"></a><span class="lineno">  623</span>&#160;}</div><div class="line"><a name="l00624"></a><span class="lineno">  624</span>&#160;</div><div class="line"><a name="l00625"></a><span class="lineno">  625</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00626"></a><span class="lineno">  626</span>&#160;</div><div class="line"><a name="l00634"></a><span class="lineno"><a class="line" href="group__DeviceInterface.html#gaf02497a3d6bb0e43dcefc1802f8666a5">  634</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="group__DeviceInterface.html#gaf02497a3d6bb0e43dcefc1802f8666a5">ecdev_receive</a>(</div><div class="line"><a name="l00635"></a><span class="lineno">  635</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device, </div><div class="line"><a name="l00636"></a><span class="lineno">  636</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">void</span> *data, </div><div class="line"><a name="l00637"></a><span class="lineno">  637</span>&#160;        <span class="keywordtype">size_t</span> size </div><div class="line"><a name="l00638"></a><span class="lineno">  638</span>&#160;        )</div><div class="line"><a name="l00639"></a><span class="lineno">  639</span>&#160;{</div><div class="line"><a name="l00640"></a><span class="lineno">  640</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">void</span> *ec_data = data + ETH_HLEN;</div><div class="line"><a name="l00641"></a><span class="lineno">  641</span>&#160;    <span class="keywordtype">size_t</span> ec_size = size - ETH_HLEN;</div><div class="line"><a name="l00642"></a><span class="lineno">  642</span>&#160;</div><div class="line"><a name="l00643"></a><span class="lineno">  643</span>&#160;    <span class="keywordflow">if</span> (unlikely(!data)) {</div><div class="line"><a name="l00644"></a><span class="lineno">  644</span>&#160;        <a class="code" href="master_8h.html#af75617c47fe87f4f60e8593d7e79dbc0">EC_MASTER_WARN</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>, <span class="stringliteral">&quot;%s() called with NULL data.\n&quot;</span>,</div><div class="line"><a name="l00645"></a><span class="lineno">  645</span>&#160;                __func__);</div><div class="line"><a name="l00646"></a><span class="lineno">  646</span>&#160;        <span class="keywordflow">return</span>;</div><div class="line"><a name="l00647"></a><span class="lineno">  647</span>&#160;    }</div><div class="line"><a name="l00648"></a><span class="lineno">  648</span>&#160;</div><div class="line"><a name="l00649"></a><span class="lineno">  649</span>&#160;    device-&gt;<a class="code" href="structec__device.html#ab53eaa1db2b7696c28f06146fd253786">rx_count</a>++;</div><div class="line"><a name="l00650"></a><span class="lineno">  650</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>-&gt;<a class="code" href="structec__master.html#a8109992ca98fdfc4d97610ec699fec31">device_stats</a>.<a class="code" href="structec__device__stats__t.html#aca29f0a6107eab8e7438ea53078183af">rx_count</a>++;</div><div class="line"><a name="l00651"></a><span class="lineno">  651</span>&#160;    device-&gt;<a class="code" href="structec__device.html#afea25f45c6911c97a08b8615154a2b91">rx_bytes</a> += size;</div><div class="line"><a name="l00652"></a><span class="lineno">  652</span>&#160;    device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>-&gt;<a class="code" href="structec__master.html#a8109992ca98fdfc4d97610ec699fec31">device_stats</a>.<a class="code" href="structec__device__stats__t.html#a7aa4d7f1b8804dfd50d0b6caef15de9f">rx_bytes</a> += size;</div><div class="line"><a name="l00653"></a><span class="lineno">  653</span>&#160;</div><div class="line"><a name="l00654"></a><span class="lineno">  654</span>&#160;    <span class="keywordflow">if</span> (unlikely(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>-&gt;<a class="code" href="structec__master.html#abdecf290f3f7f2af1b2a7bf0d9c7b08d">debug_level</a> &gt; 1)) {</div><div class="line"><a name="l00655"></a><span class="lineno">  655</span>&#160;        <a class="code" href="master_8h.html#a6cc0dea5aa374291f2379e844de741d0">EC_MASTER_DBG</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>, 2, <span class="stringliteral">&quot;Received frame:\n&quot;</span>);</div><div class="line"><a name="l00656"></a><span class="lineno">  656</span>&#160;        <a class="code" href="globals_8h.html#af9b1cee5f8eb11448141bd02d52f44ac">ec_print_data</a>(data, size);</div><div class="line"><a name="l00657"></a><span class="lineno">  657</span>&#160;    }</div><div class="line"><a name="l00658"></a><span class="lineno">  658</span>&#160;</div><div class="line"><a name="l00659"></a><span class="lineno">  659</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_IF</span></div><div class="line"><a name="l00660"></a><span class="lineno">  660</span>&#160;    <a class="code" href="debug_8c.html#af11807b9c95c1c4f05aa0cd5a672a560">ec_debug_send</a>(&amp;device-&gt;dbg, data, size);</div><div class="line"><a name="l00661"></a><span class="lineno">  661</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00662"></a><span class="lineno">  662</span>&#160;<span class="preprocessor">#ifdef EC_DEBUG_RING</span></div><div class="line"><a name="l00663"></a><span class="lineno">  663</span>&#160;    ec_device_debug_ring_append(device, RX, ec_data, ec_size);</div><div class="line"><a name="l00664"></a><span class="lineno">  664</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00665"></a><span class="lineno">  665</span>&#160;</div><div class="line"><a name="l00666"></a><span class="lineno">  666</span>&#160;    <a class="code" href="master_8c.html#a64c31b83d02d9d7b92ee78396115d352">ec_master_receive_datagrams</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>, ec_data, ec_size);</div><div class="line"><a name="l00667"></a><span class="lineno">  667</span>&#160;}</div><div class="line"><a name="l00668"></a><span class="lineno">  668</span>&#160;</div><div class="line"><a name="l00669"></a><span class="lineno">  669</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00670"></a><span class="lineno">  670</span>&#160;</div><div class="line"><a name="l00678"></a><span class="lineno"><a class="line" href="group__DeviceInterface.html#gac1d0e31b8b60ad4e94c03148aac88499">  678</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="group__DeviceInterface.html#gac1d0e31b8b60ad4e94c03148aac88499">ecdev_set_link</a>(</div><div class="line"><a name="l00679"></a><span class="lineno">  679</span>&#160;        <a class="code" href="structec__device.html">ec_device_t</a> *device, </div><div class="line"><a name="l00680"></a><span class="lineno">  680</span>&#160;        uint8_t state </div><div class="line"><a name="l00681"></a><span class="lineno">  681</span>&#160;        )</div><div class="line"><a name="l00682"></a><span class="lineno">  682</span>&#160;{</div><div class="line"><a name="l00683"></a><span class="lineno">  683</span>&#160;    <span class="keywordflow">if</span> (unlikely(!device)) {</div><div class="line"><a name="l00684"></a><span class="lineno">  684</span>&#160;        <a class="code" href="globals_8h.html#a268d5c7947aba061aee9ba26ae5e54cf">EC_WARN</a>(<span class="stringliteral">&quot;ecdev_set_link() called with null device!\n&quot;</span>);</div><div class="line"><a name="l00685"></a><span class="lineno">  685</span>&#160;        <span class="keywordflow">return</span>;</div><div class="line"><a name="l00686"></a><span class="lineno">  686</span>&#160;    }</div><div class="line"><a name="l00687"></a><span class="lineno">  687</span>&#160;</div><div class="line"><a name="l00688"></a><span class="lineno">  688</span>&#160;    <span class="keywordflow">if</span> (likely(state != device-&gt;<a class="code" href="structec__device.html#ab58236227ed28e568e0de571499d5e68">link_state</a>)) {</div><div class="line"><a name="l00689"></a><span class="lineno">  689</span>&#160;        device-&gt;<a class="code" href="structec__device.html#ab58236227ed28e568e0de571499d5e68">link_state</a> = state;</div><div class="line"><a name="l00690"></a><span class="lineno">  690</span>&#160;        <a class="code" href="master_8h.html#a306a2bcfad973302ae507c9c6978b816">EC_MASTER_INFO</a>(device-&gt;<a class="code" href="structec__device.html#a3678edcc317d6324936b02c4509de443">master</a>,</div><div class="line"><a name="l00691"></a><span class="lineno">  691</span>&#160;                <span class="stringliteral">&quot;Link state of %s changed to %s.\n&quot;</span>,</div><div class="line"><a name="l00692"></a><span class="lineno">  692</span>&#160;                device-&gt;<a class="code" href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">dev</a>-&gt;name, (state ? <span class="stringliteral">&quot;UP&quot;</span> : <span class="stringliteral">&quot;DOWN&quot;</span>));</div><div class="line"><a name="l00693"></a><span class="lineno">  693</span>&#160;    }</div><div class="line"><a name="l00694"></a><span class="lineno">  694</span>&#160;}</div><div class="line"><a name="l00695"></a><span class="lineno">  695</span>&#160;</div><div class="line"><a name="l00696"></a><span class="lineno">  696</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00697"></a><span class="lineno">  697</span>&#160;</div><div class="line"><a name="l00704"></a><span class="lineno"><a class="line" href="group__DeviceInterface.html#gaa31bc8d955fea01e8430105c61064589">  704</a></span>&#160;uint8_t <a class="code" href="group__DeviceInterface.html#gaa31bc8d955fea01e8430105c61064589">ecdev_get_link</a>(</div><div class="line"><a name="l00705"></a><span class="lineno">  705</span>&#160;        <span class="keyword">const</span> <a class="code" href="structec__device.html">ec_device_t</a> *device </div><div class="line"><a name="l00706"></a><span class="lineno">  706</span>&#160;        )</div><div class="line"><a name="l00707"></a><span class="lineno">  707</span>&#160;{</div><div class="line"><a name="l00708"></a><span class="lineno">  708</span>&#160;    <span class="keywordflow">if</span> (unlikely(!device)) {</div><div class="line"><a name="l00709"></a><span class="lineno">  709</span>&#160;        <a class="code" href="globals_8h.html#a268d5c7947aba061aee9ba26ae5e54cf">EC_WARN</a>(<span class="stringliteral">&quot;ecdev_get_link() called with null device!\n&quot;</span>);</div><div class="line"><a name="l00710"></a><span class="lineno">  710</span>&#160;        <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00711"></a><span class="lineno">  711</span>&#160;    }</div><div class="line"><a name="l00712"></a><span class="lineno">  712</span>&#160;</div><div class="line"><a name="l00713"></a><span class="lineno">  713</span>&#160;    <span class="keywordflow">return</span> device-&gt;<a class="code" href="structec__device.html#ab58236227ed28e568e0de571499d5e68">link_state</a>;</div><div class="line"><a name="l00714"></a><span class="lineno">  714</span>&#160;}</div><div class="line"><a name="l00715"></a><span class="lineno">  715</span>&#160;</div><div class="line"><a name="l00716"></a><span class="lineno">  716</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="line"><a name="l00717"></a><span class="lineno">  717</span>&#160;</div><div class="line"><a name="l00720"></a><span class="lineno">  720</span>&#160;EXPORT_SYMBOL(<a class="code" href="group__DeviceInterface.html#ga3934f8a07aa394d558147d790fc60a8b">ecdev_withdraw</a>);</div><div class="line"><a name="l00721"></a><span class="lineno">  721</span>&#160;EXPORT_SYMBOL(<a class="code" href="group__DeviceInterface.html#ga34eceaecfe6ab4fe8f0ecde1a3b311c4">ecdev_open</a>);</div><div class="line"><a name="l00722"></a><span class="lineno">  722</span>&#160;EXPORT_SYMBOL(<a class="code" href="group__DeviceInterface.html#ga0a6b26b2397aa49cc82915a12b8cc854">ecdev_close</a>);</div><div class="line"><a name="l00723"></a><span class="lineno">  723</span>&#160;EXPORT_SYMBOL(<a class="code" href="group__DeviceInterface.html#gaf02497a3d6bb0e43dcefc1802f8666a5">ecdev_receive</a>);</div><div class="line"><a name="l00724"></a><span class="lineno">  724</span>&#160;EXPORT_SYMBOL(<a class="code" href="group__DeviceInterface.html#gaa31bc8d955fea01e8430105c61064589">ecdev_get_link</a>);</div><div class="line"><a name="l00725"></a><span class="lineno">  725</span>&#160;EXPORT_SYMBOL(<a class="code" href="group__DeviceInterface.html#gac1d0e31b8b60ad4e94c03148aac88499">ecdev_set_link</a>);</div><div class="line"><a name="l00726"></a><span class="lineno">  726</span>&#160;</div><div class="line"><a name="l00729"></a><span class="lineno">  729</span>&#160;<span class="comment">/*****************************************************************************/</span></div><div class="ttc" id="globals_8h_html_a268d5c7947aba061aee9ba26ae5e54cf"><div class="ttname"><a href="globals_8h.html#a268d5c7947aba061aee9ba26ae5e54cf">EC_WARN</a></div><div class="ttdeci">#define EC_WARN(fmt, args...)</div><div class="ttdoc">Convenience macro for printing EtherCAT-specific warnings to syslog. </div><div class="ttdef"><b>Definition:</b> <a href="globals_8h_source.html#l00237">globals.h:237</a></div></div>
<div class="ttc" id="structec__device_html_a733aeb60035ac3696f05dc33adf49004"><div class="ttname"><a href="structec__device.html#a733aeb60035ac3696f05dc33adf49004">ec_device::tx_skb</a></div><div class="ttdeci">struct sk_buff * tx_skb[EC_TX_RING_SIZE]</div><div class="ttdoc">transmit skb ring </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00089">device.h:89</a></div></div>
<div class="ttc" id="structec__device__stats__t_html_a712dc5c0b9652b59fe8dfda4cd5cb0fe"><div class="ttname"><a href="structec__device__stats__t.html#a712dc5c0b9652b59fe8dfda4cd5cb0fe">ec_device_stats_t::tx_count</a></div><div class="ttdeci">u64 tx_count</div><div class="ttdoc">Number of frames sent. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00156">master.h:156</a></div></div>
<div class="ttc" id="master_8c_html_a07848f103b98208d90a6fec920790500"><div class="ttname"><a href="master_8c.html#a07848f103b98208d90a6fec920790500">rate_intervals</a></div><div class="ttdeci">const unsigned int rate_intervals[]</div><div class="ttdoc">List of intervals for statistics [s]. </div><div class="ttdef"><b>Definition:</b> <a href="master_8c_source.html#l00087">master.c:87</a></div></div>
<div class="ttc" id="group__DeviceInterface_html_ga0a6b26b2397aa49cc82915a12b8cc854"><div class="ttname"><a href="group__DeviceInterface.html#ga0a6b26b2397aa49cc82915a12b8cc854">ecdev_close</a></div><div class="ttdeci">void ecdev_close(ec_device_t *device)</div><div class="ttdoc">Makes the master leave IDLE phase and closes the network device. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00612">device.c:612</a></div></div>
<div class="ttc" id="structec__device_html_aa51d769eb590a04e98f8544ea758322f"><div class="ttname"><a href="structec__device.html#aa51d769eb590a04e98f8544ea758322f">ec_device::poll</a></div><div class="ttdeci">ec_pollfunc_t poll</div><div class="ttdoc">pointer to the device&amp;#39;s poll function </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00085">device.h:85</a></div></div>
<div class="ttc" id="debug_8c_html_a1711152b73dc97bc81a9e9aae4b8a263"><div class="ttname"><a href="debug_8c.html#a1711152b73dc97bc81a9e9aae4b8a263">ec_debug_clear</a></div><div class="ttdeci">void ec_debug_clear(ec_debug_t *dbg)</div><div class="ttdoc">Debug interface destructor. </div><div class="ttdef"><b>Definition:</b> <a href="debug_8c_source.html#l00115">debug.c:115</a></div></div>
<div class="ttc" id="structec__device_html_af98c616a488455db59c5c4297206b8fb"><div class="ttname"><a href="structec__device.html#af98c616a488455db59c5c4297206b8fb">ec_device::jiffies_poll</a></div><div class="ttdeci">unsigned long jiffies_poll</div><div class="ttdoc">jiffies of last poll </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00097">device.h:97</a></div></div>
<div class="ttc" id="structec__device_html_afca221601cff7e6280283df48902a019"><div class="ttname"><a href="structec__device.html#afca221601cff7e6280283df48902a019">ec_device::last_tx_count</a></div><div class="ttdeci">u64 last_tx_count</div><div class="ttdoc">Number of frames sent of last statistics cycle. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00101">device.h:101</a></div></div>
<div class="ttc" id="master_8h_html_a27e6deff35543c304e8a191c64f35cf3"><div class="ttname"><a href="master_8h.html#a27e6deff35543c304e8a191c64f35cf3">ec_master_num_devices</a></div><div class="ttdeci">#define ec_master_num_devices(MASTER)</div><div class="ttdoc">Number of Ethernet devices. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00328">master.h:328</a></div></div>
<div class="ttc" id="globals_8h_html_a00b477d166c2d09b9fea5d43c0c1cd48"><div class="ttname"><a href="globals_8h.html#a00b477d166c2d09b9fea5d43c0c1cd48">EC_RATE_COUNT</a></div><div class="ttdeci">#define EC_RATE_COUNT</div><div class="ttdoc">Number of statistic rate intervals to maintain. </div><div class="ttdef"><b>Definition:</b> <a href="globals_8h_source.html#l00072">globals.h:72</a></div></div>
<div class="ttc" id="group__DeviceInterface_html_ga34eceaecfe6ab4fe8f0ecde1a3b311c4"><div class="ttname"><a href="group__DeviceInterface.html#ga34eceaecfe6ab4fe8f0ecde1a3b311c4">ecdev_open</a></div><div class="ttdeci">int ecdev_open(ec_device_t *device)</div><div class="ttdoc">Opens the network device and makes the master enter IDLE phase. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00574">device.c:574</a></div></div>
<div class="ttc" id="structec__device_html_a79af9075672aa2abf993a703b4d964ed"><div class="ttname"><a href="structec__device.html#a79af9075672aa2abf993a703b4d964ed">ec_device::module</a></div><div class="ttdeci">struct module * module</div><div class="ttdoc">pointer to the device&amp;#39;s owning module </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00086">device.h:86</a></div></div>
<div class="ttc" id="device_8c_html_ad42f994e302efd7c59fc64bfc84f6037"><div class="ttname"><a href="device_8c.html#ad42f994e302efd7c59fc64bfc84f6037">ec_device_clear</a></div><div class="ttdeci">void ec_device_clear(ec_device_t *device)</div><div class="ttdoc">Destructor. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00162">device.c:162</a></div></div>
<div class="ttc" id="device_8c_html_aec3d7ce9ab236b9626efefbc8c2ffd96"><div class="ttname"><a href="device_8c.html#aec3d7ce9ab236b9626efefbc8c2ffd96">ec_device_open</a></div><div class="ttdeci">int ec_device_open(ec_device_t *device)</div><div class="ttdoc">Opens the EtherCAT device. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00242">device.c:242</a></div></div>
<div class="ttc" id="structec__device_html_a0de91079b171a6b07cb724a6362f340b"><div class="ttname"><a href="structec__device.html#a0de91079b171a6b07cb724a6362f340b">ec_device::tx_frame_rates</a></div><div class="ttdeci">s32 tx_frame_rates[EC_RATE_COUNT]</div><div class="ttdoc">Transmit rates in frames/s for different statistics cycle periods. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00111">device.h:111</a></div></div>
<div class="ttc" id="device_8c_html_a158275fbb94b82be5d551044f38981f4"><div class="ttname"><a href="device_8c.html#a158275fbb94b82be5d551044f38981f4">ec_device_update_stats</a></div><div class="ttdeci">void ec_device_update_stats(ec_device_t *device)</div><div class="ttdoc">Update device statistics. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00496">device.c:496</a></div></div>
<div class="ttc" id="structec__device_html_ab58236227ed28e568e0de571499d5e68"><div class="ttname"><a href="structec__device.html#ab58236227ed28e568e0de571499d5e68">ec_device::link_state</a></div><div class="ttdeci">uint8_t link_state</div><div class="ttdoc">device link state </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00088">device.h:88</a></div></div>
<div class="ttc" id="structec__device_html_ab53eaa1db2b7696c28f06146fd253786"><div class="ttname"><a href="structec__device.html#ab53eaa1db2b7696c28f06146fd253786">ec_device::rx_count</a></div><div class="ttdeci">u64 rx_count</div><div class="ttdoc">Number of frames received. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00102">device.h:102</a></div></div>
<div class="ttc" id="structec__device_html_ac4a738c0943134edc5c68f2c85b9a089"><div class="ttname"><a href="structec__device.html#ac4a738c0943134edc5c68f2c85b9a089">ec_device::last_tx_bytes</a></div><div class="ttdeci">u64 last_tx_bytes</div><div class="ttdoc">Number of bytes sent of last statistics cycle. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00106">device.h:106</a></div></div>
<div class="ttc" id="master_8c_html_a64c31b83d02d9d7b92ee78396115d352"><div class="ttname"><a href="master_8c.html#a64c31b83d02d9d7b92ee78396115d352">ec_master_receive_datagrams</a></div><div class="ttdeci">void ec_master_receive_datagrams(ec_master_t *master, const uint8_t *frame_data, size_t size)</div><div class="ttdoc">Processes a received frame. </div><div class="ttdef"><b>Definition:</b> <a href="master_8c_source.html#l01109">master.c:1109</a></div></div>
<div class="ttc" id="master_8c_html_a953107732b8b44631afcb3d2f82964a0"><div class="ttname"><a href="master_8c.html#a953107732b8b44631afcb3d2f82964a0">ec_master_enter_idle_phase</a></div><div class="ttdeci">int ec_master_enter_idle_phase(ec_master_t *master)</div><div class="ttdoc">Transition function from ORPHANED to IDLE phase. </div><div class="ttdef"><b>Definition:</b> <a href="master_8c_source.html#l00620">master.c:620</a></div></div>
<div class="ttc" id="structec__device_html_a8e78783b1d22fd12b5d2abe263184bb1"><div class="ttname"><a href="structec__device.html#a8e78783b1d22fd12b5d2abe263184bb1">ec_device::rx_frame_rates</a></div><div class="ttdeci">s32 rx_frame_rates[EC_RATE_COUNT]</div><div class="ttdoc">Receive rates in frames/s for different statistics cycle periods. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00114">device.h:114</a></div></div>
<div class="ttc" id="master_8h_html"><div class="ttname"><a href="master_8h.html">master.h</a></div><div class="ttdoc">EtherCAT master structure. </div></div>
<div class="ttc" id="debug_8c_html_a488b3c97e9786a33f2372180de561591"><div class="ttname"><a href="debug_8c.html#a488b3c97e9786a33f2372180de561591">ec_debug_unregister</a></div><div class="ttdeci">void ec_debug_unregister(ec_debug_t *dbg)</div><div class="ttdoc">Unregister debug interface. </div><div class="ttdef"><b>Definition:</b> <a href="debug_8c_source.html#l00152">debug.c:152</a></div></div>
<div class="ttc" id="device_8c_html_ad46f8a21db1dd635d52bbae01b3f467f"><div class="ttname"><a href="device_8c.html#ad46f8a21db1dd635d52bbae01b3f467f">ec_device_send</a></div><div class="ttdeci">void ec_device_send(ec_device_t *device, size_t size)</div><div class="ttdoc">Sends the content of the transmit socket buffer. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00331">device.c:331</a></div></div>
<div class="ttc" id="master_8h_html_a6cc0dea5aa374291f2379e844de741d0"><div class="ttname"><a href="master_8h.html#a6cc0dea5aa374291f2379e844de741d0">EC_MASTER_DBG</a></div><div class="ttdeci">#define EC_MASTER_DBG(master, level, fmt, args...)</div><div class="ttdoc">Convenience macro for printing master-specific debug messages to syslog. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00111">master.h:111</a></div></div>
<div class="ttc" id="device_8h_html_a8e81effb90ab4150ac1fe4114e7775f0"><div class="ttname"><a href="device_8h.html#a8e81effb90ab4150ac1fe4114e7775f0">EC_TX_RING_SIZE</a></div><div class="ttdeci">#define EC_TX_RING_SIZE</div><div class="ttdoc">Size of the transmit ring. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00051">device.h:51</a></div></div>
<div class="ttc" id="structec__master_html_a8109992ca98fdfc4d97610ec699fec31"><div class="ttname"><a href="structec__master.html#a8109992ca98fdfc4d97610ec699fec31">ec_master::device_stats</a></div><div class="ttdeci">ec_device_stats_t device_stats</div><div class="ttdoc">Device statistics. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00219">master.h:219</a></div></div>
<div class="ttc" id="structec__device_html_a5ad25fde7d43696988dcb602fa947a7b"><div class="ttname"><a href="structec__device.html#a5ad25fde7d43696988dcb602fa947a7b">ec_device::last_rx_count</a></div><div class="ttdeci">u64 last_rx_count</div><div class="ttdoc">Number of frames received of last statistics cycle. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00103">device.h:103</a></div></div>
<div class="ttc" id="structec__master_html_aeeac95bdfc711903f48710b31e8b78a2"><div class="ttname"><a href="structec__master.html#aeeac95bdfc711903f48710b31e8b78a2">ec_master::phase</a></div><div class="ttdeci">ec_master_phase_t phase</div><div class="ttdoc">Master phase. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00223">master.h:223</a></div></div>
<div class="ttc" id="ecdev_8h_html_a789bcd88d869f88c58bd13b451b3fd52"><div class="ttname"><a href="ecdev_8h.html#a789bcd88d869f88c58bd13b451b3fd52">ec_pollfunc_t</a></div><div class="ttdeci">void(* ec_pollfunc_t)(struct net_device *)</div><div class="ttdoc">Device poll function type. </div><div class="ttdef"><b>Definition:</b> <a href="ecdev_8h_source.html#l00057">ecdev.h:57</a></div></div>
<div class="ttc" id="structec__master_html_acbd28a1ea76d9b758e53a987b18a59c7"><div class="ttname"><a href="structec__master.html#acbd28a1ea76d9b758e53a987b18a59c7">ec_master::device_sem</a></div><div class="ttdeci">struct semaphore device_sem</div><div class="ttdoc">Device semaphore. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00218">master.h:218</a></div></div>
<div class="ttc" id="structec__device_html_a577e0651d974aa3db43fcb8fab639637"><div class="ttname"><a href="structec__device.html#a577e0651d974aa3db43fcb8fab639637">ec_device::rx_byte_rates</a></div><div class="ttdeci">s32 rx_byte_rates[EC_RATE_COUNT]</div><div class="ttdoc">Receive rates in byte/s for different statistics cycle periods. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00119">device.h:119</a></div></div>
<div class="ttc" id="structec__device_html"><div class="ttname"><a href="structec__device.html">ec_device</a></div><div class="ttdoc">EtherCAT device. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00081">device.h:81</a></div></div>
<div class="ttc" id="structec__device_html_af9353b63b910b0b64d06837b3f7075b7"><div class="ttname"><a href="structec__device.html#af9353b63b910b0b64d06837b3f7075b7">ec_device::tx_ring_index</a></div><div class="ttdeci">unsigned int tx_ring_index</div><div class="ttdoc">last ring entry used to transmit </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00090">device.h:90</a></div></div>
<div class="ttc" id="structec__master_html_abdecf290f3f7f2af1b2a7bf0d9c7b08d"><div class="ttname"><a href="structec__master.html#abdecf290f3f7f2af1b2a7bf0d9c7b08d">ec_master::debug_level</a></div><div class="ttdeci">unsigned int debug_level</div><div class="ttdoc">Master debug level. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00286">master.h:286</a></div></div>
<div class="ttc" id="master_8c_html_a064c1933a370bf502e0bf42e15ae45f9"><div class="ttname"><a href="master_8c.html#a064c1933a370bf502e0bf42e15ae45f9">ec_master_leave_idle_phase</a></div><div class="ttdeci">void ec_master_leave_idle_phase(ec_master_t *master)</div><div class="ttdoc">Transition function from IDLE to ORPHANED phase. </div><div class="ttdef"><b>Definition:</b> <a href="master_8c_source.html#l00653">master.c:653</a></div></div>
<div class="ttc" id="structec__device_html_a5decb734bd07c7e1a1b66e08904f0bba"><div class="ttname"><a href="structec__device.html#a5decb734bd07c7e1a1b66e08904f0bba">ec_device::tx_byte_rates</a></div><div class="ttdeci">s32 tx_byte_rates[EC_RATE_COUNT]</div><div class="ttdoc">Transmit rates in byte/s for different statistics cycle periods. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00117">device.h:117</a></div></div>
<div class="ttc" id="globals_8h_html_ad1a2101422888687598d7e1a630c6343a6cc7c24499003f339df547ab73605f13"><div class="ttname"><a href="globals_8h.html#ad1a2101422888687598d7e1a630c6343a6cc7c24499003f339df547ab73605f13">EC_DEVICE_MAIN</a></div><div class="ttdoc">Main device. </div><div class="ttdef"><b>Definition:</b> <a href="globals_8h_source.html#l00202">globals.h:202</a></div></div>
<div class="ttc" id="device_8c_html_a4984e3e354110c1f4694fd521491cc30"><div class="ttname"><a href="device_8c.html#a4984e3e354110c1f4694fd521491cc30">ec_device_init</a></div><div class="ttdeci">int ec_device_init(ec_device_t *device, ec_master_t *master)</div><div class="ttdoc">Constructor. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00063">device.c:63</a></div></div>
<div class="ttc" id="master_8h_html_af75617c47fe87f4f60e8593d7e79dbc0"><div class="ttname"><a href="master_8h.html#af75617c47fe87f4f60e8593d7e79dbc0">EC_MASTER_WARN</a></div><div class="ttdeci">#define EC_MASTER_WARN(master, fmt, args...)</div><div class="ttdoc">Convenience macro for printing master-specific warnings to syslog. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00097">master.h:97</a></div></div>
<div class="ttc" id="structec__device_html_a3678edcc317d6324936b02c4509de443"><div class="ttname"><a href="structec__device.html#a3678edcc317d6324936b02c4509de443">ec_device::master</a></div><div class="ttdeci">ec_master_t * master</div><div class="ttdoc">EtherCAT master. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00083">device.h:83</a></div></div>
<div class="ttc" id="structec__device_html_afea25f45c6911c97a08b8615154a2b91"><div class="ttname"><a href="structec__device.html#afea25f45c6911c97a08b8615154a2b91">ec_device::rx_bytes</a></div><div class="ttdeci">u64 rx_bytes</div><div class="ttdoc">Number of bytes received. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00107">device.h:107</a></div></div>
<div class="ttc" id="structec__device_html_a0cdf625147761dedcd8aa0ee08434949"><div class="ttname"><a href="structec__device.html#a0cdf625147761dedcd8aa0ee08434949">ec_device::tx_count</a></div><div class="ttdeci">u64 tx_count</div><div class="ttdoc">Number of frames sent. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00100">device.h:100</a></div></div>
<div class="ttc" id="group__DeviceInterface_html_gaa31bc8d955fea01e8430105c61064589"><div class="ttname"><a href="group__DeviceInterface.html#gaa31bc8d955fea01e8430105c61064589">ecdev_get_link</a></div><div class="ttdeci">uint8_t ecdev_get_link(const ec_device_t *device)</div><div class="ttdoc">Reads the link state. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00704">device.c:704</a></div></div>
<div class="ttc" id="master_8h_html_aece1fb7ea6af168ba7513c9d7b0a523a"><div class="ttname"><a href="master_8h.html#aece1fb7ea6af168ba7513c9d7b0a523a">EC_MASTER_ERR</a></div><div class="ttdeci">#define EC_MASTER_ERR(master, fmt, args...)</div><div class="ttdoc">Convenience macro for printing master-specific errors to syslog. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00085">master.h:85</a></div></div>
<div class="ttc" id="debug_8c_html_af11807b9c95c1c4f05aa0cd5a672a560"><div class="ttname"><a href="debug_8c.html#af11807b9c95c1c4f05aa0cd5a672a560">ec_debug_send</a></div><div class="ttdeci">void ec_debug_send(ec_debug_t *dbg, const uint8_t *data, size_t size)</div><div class="ttdoc">Sends frame data to the interface. </div><div class="ttdef"><b>Definition:</b> <a href="debug_8c_source.html#l00167">debug.c:167</a></div></div>
<div class="ttc" id="debug_8c_html_a683a1dd06041ed934990c736ab3267a9"><div class="ttname"><a href="debug_8c.html#a683a1dd06041ed934990c736ab3267a9">ec_debug_register</a></div><div class="ttdeci">void ec_debug_register(ec_debug_t *dbg, const struct net_device *net_dev)</div><div class="ttdoc">Register debug interface. </div><div class="ttdef"><b>Definition:</b> <a href="debug_8c_source.html#l00127">debug.c:127</a></div></div>
<div class="ttc" id="debug_8c_html_ab4a40ce6bb6a66bd034790c3a7985c80"><div class="ttname"><a href="debug_8c.html#ab4a40ce6bb6a66bd034790c3a7985c80">ec_debug_init</a></div><div class="ttdeci">int ec_debug_init(ec_debug_t *dbg, ec_device_t *device, const char *name)</div><div class="ttdoc">Debug interface constructor. </div><div class="ttdef"><b>Definition:</b> <a href="debug_8c_source.html#l00074">debug.c:74</a></div></div>
<div class="ttc" id="device_8c_html_ac301d857a14ce98a79ffb12a7757bd09"><div class="ttname"><a href="device_8c.html#ac301d857a14ce98a79ffb12a7757bd09">ec_device_tx_data</a></div><div class="ttdeci">uint8_t * ec_device_tx_data(ec_device_t *device)</div><div class="ttdoc">Returns a pointer to the device&amp;#39;s transmit memory. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00312">device.c:312</a></div></div>
<div class="ttc" id="globals_8h_html_af9b1cee5f8eb11448141bd02d52f44ac"><div class="ttname"><a href="globals_8h.html#af9b1cee5f8eb11448141bd02d52f44ac">ec_print_data</a></div><div class="ttdeci">void ec_print_data(const uint8_t *, size_t)</div><div class="ttdoc">Outputs frame contents for debugging purposes. </div><div class="ttdef"><b>Definition:</b> <a href="module_8c_source.html#l00341">module.c:341</a></div></div>
<div class="ttc" id="master_8h_html_aebcf0998049ecde580a47832fb3b36f0a243c4f44013cdfedb1105cb13e6b1191"><div class="ttname"><a href="master_8h.html#aebcf0998049ecde580a47832fb3b36f0a243c4f44013cdfedb1105cb13e6b1191">EC_IDLE</a></div><div class="ttdoc">Idle phase. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00133">master.h:133</a></div></div>
<div class="ttc" id="structec__device_html_a0a3f5a12926e0d4ef17409d05b36d18a"><div class="ttname"><a href="structec__device.html#a0a3f5a12926e0d4ef17409d05b36d18a">ec_device::open</a></div><div class="ttdeci">uint8_t open</div><div class="ttdoc">true, if the net_device has been opened </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00087">device.h:87</a></div></div>
<div class="ttc" id="structec__device_html_a076ce4fd0d53e53ba7236b12bf4ecf66"><div class="ttname"><a href="structec__device.html#a076ce4fd0d53e53ba7236b12bf4ecf66">ec_device::tx_errors</a></div><div class="ttdeci">u64 tx_errors</div><div class="ttdoc">Number of transmit errors. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00110">device.h:110</a></div></div>
<div class="ttc" id="globals_8h_html_a494695f2cebf0403348cb6281e0af0c9"><div class="ttname"><a href="globals_8h.html#a494695f2cebf0403348cb6281e0af0c9">ec_mac_print</a></div><div class="ttdeci">ssize_t ec_mac_print(const uint8_t *, char *)</div><div class="ttdoc">Print a MAC address to a buffer. </div><div class="ttdef"><b>Definition:</b> <a href="module_8c_source.html#l00242">module.c:242</a></div></div>
<div class="ttc" id="structec__device_html_a53f0337afe2d2bdb4b24e2ee4ccb8180"><div class="ttname"><a href="structec__device.html#a53f0337afe2d2bdb4b24e2ee4ccb8180">ec_device::last_rx_bytes</a></div><div class="ttdeci">u64 last_rx_bytes</div><div class="ttdoc">Number of bytes received of last statistics cycle. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00108">device.h:108</a></div></div>
<div class="ttc" id="structec__device__stats__t_html_ac4bcb52ad4f765671ffe124f4019b370"><div class="ttname"><a href="structec__device__stats__t.html#ac4bcb52ad4f765671ffe124f4019b370">ec_device_stats_t::tx_bytes</a></div><div class="ttdeci">u64 tx_bytes</div><div class="ttdoc">Number of bytes sent. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00161">master.h:161</a></div></div>
<div class="ttc" id="group__DeviceInterface_html_gaf02497a3d6bb0e43dcefc1802f8666a5"><div class="ttname"><a href="group__DeviceInterface.html#gaf02497a3d6bb0e43dcefc1802f8666a5">ecdev_receive</a></div><div class="ttdeci">void ecdev_receive(ec_device_t *device, const void *data, size_t size)</div><div class="ttdoc">Accepts a received frame. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00634">device.c:634</a></div></div>
<div class="ttc" id="device_8c_html_a1d4eadd4b9da0e4298818434e1b78a9a"><div class="ttname"><a href="device_8c.html#a1d4eadd4b9da0e4298818434e1b78a9a">ec_device_close</a></div><div class="ttdeci">int ec_device_close(ec_device_t *device)</div><div class="ttdoc">Stops the EtherCAT device. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00279">device.c:279</a></div></div>
<div class="ttc" id="structec__device__stats__t_html_aca29f0a6107eab8e7438ea53078183af"><div class="ttname"><a href="structec__device__stats__t.html#aca29f0a6107eab8e7438ea53078183af">ec_device_stats_t::rx_count</a></div><div class="ttdeci">u64 rx_count</div><div class="ttdoc">Number of frames received. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00158">master.h:158</a></div></div>
<div class="ttc" id="group__DeviceInterface_html_gac1d0e31b8b60ad4e94c03148aac88499"><div class="ttname"><a href="group__DeviceInterface.html#gac1d0e31b8b60ad4e94c03148aac88499">ecdev_set_link</a></div><div class="ttdeci">void ecdev_set_link(ec_device_t *device, uint8_t state)</div><div class="ttdoc">Sets a new link state. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00678">device.c:678</a></div></div>
<div class="ttc" id="device_8c_html_a20976f86443d49ebf67caf83d4c0e156"><div class="ttname"><a href="device_8c.html#a20976f86443d49ebf67caf83d4c0e156">ec_device_attach</a></div><div class="ttdeci">void ec_device_attach(ec_device_t *device, struct net_device *net_dev, ec_pollfunc_t poll, struct module *module)</div><div class="ttdoc">Associate with net_device. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00182">device.c:182</a></div></div>
<div class="ttc" id="device_8c_html_a12e63c43b18c206ba32fdb2a3d668bb8"><div class="ttname"><a href="device_8c.html#a12e63c43b18c206ba32fdb2a3d668bb8">ec_device_detach</a></div><div class="ttdeci">void ec_device_detach(ec_device_t *device)</div><div class="ttdoc">Disconnect from net_device. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00213">device.c:213</a></div></div>
<div class="ttc" id="device_8h_html"><div class="ttname"><a href="device_8h.html">device.h</a></div><div class="ttdoc">EtherCAT device structure. </div></div>
<div class="ttc" id="structec__device_html_a9503692598d3950969ca8b4daf5fd5ac"><div class="ttname"><a href="structec__device.html#a9503692598d3950969ca8b4daf5fd5ac">ec_device::dev</a></div><div class="ttdeci">struct net_device * dev</div><div class="ttdoc">pointer to the assigned net_device </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00084">device.h:84</a></div></div>
<div class="ttc" id="device_8c_html_a6944619b6e1c0f85d5f7d124a0a71af2"><div class="ttname"><a href="device_8c.html#a6944619b6e1c0f85d5f7d124a0a71af2">ec_device_poll</a></div><div class="ttdeci">void ec_device_poll(ec_device_t *device)</div><div class="ttdoc">Calls the poll function of the assigned net_device. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00478">device.c:478</a></div></div>
<div class="ttc" id="structec__master_html_a78fe13519ced082c9a212711bec49ed3"><div class="ttname"><a href="structec__master.html#a78fe13519ced082c9a212711bec49ed3">ec_master::index</a></div><div class="ttdeci">unsigned int index</div><div class="ttdoc">Index. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00195">master.h:195</a></div></div>
<div class="ttc" id="globals_8h_html_ad1a2101422888687598d7e1a630c6343ab269739586dbb817c1e0ff42e74c5111"><div class="ttname"><a href="globals_8h.html#ad1a2101422888687598d7e1a630c6343ab269739586dbb817c1e0ff42e74c5111">EC_DEVICE_BACKUP</a></div><div class="ttdoc">Backup device. </div><div class="ttdef"><b>Definition:</b> <a href="globals_8h_source.html#l00203">globals.h:203</a></div></div>
<div class="ttc" id="group__DeviceInterface_html_ga3934f8a07aa394d558147d790fc60a8b"><div class="ttname"><a href="group__DeviceInterface.html#ga3934f8a07aa394d558147d790fc60a8b">ecdev_withdraw</a></div><div class="ttdeci">void ecdev_withdraw(ec_device_t *device)</div><div class="ttdoc">Withdraws an EtherCAT device from the master. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00543">device.c:543</a></div></div>
<div class="ttc" id="structec__device__stats__t_html_a7aa4d7f1b8804dfd50d0b6caef15de9f"><div class="ttname"><a href="structec__device__stats__t.html#a7aa4d7f1b8804dfd50d0b6caef15de9f">ec_device_stats_t::rx_bytes</a></div><div class="ttdeci">u64 rx_bytes</div><div class="ttdoc">Number of bytes received. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00163">master.h:163</a></div></div>
<div class="ttc" id="master_8h_html_a306a2bcfad973302ae507c9c6978b816"><div class="ttname"><a href="master_8h.html#a306a2bcfad973302ae507c9c6978b816">EC_MASTER_INFO</a></div><div class="ttdeci">#define EC_MASTER_INFO(master, fmt, args...)</div><div class="ttdoc">Convenience macro for printing master-specific information to syslog. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00073">master.h:73</a></div></div>
<div class="ttc" id="structec__master_html"><div class="ttname"><a href="structec__master.html">ec_master</a></div><div class="ttdoc">EtherCAT master. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00194">master.h:194</a></div></div>
<div class="ttc" id="structec__master_html_af339cc3b68bceb8ce25b02f4d8b5891b"><div class="ttname"><a href="structec__master.html#af339cc3b68bceb8ce25b02f4d8b5891b">ec_master::devices</a></div><div class="ttdeci">ec_device_t devices[EC_MAX_NUM_DEVICES]</div><div class="ttdoc">EtherCAT devices. </div><div class="ttdef"><b>Definition:</b> <a href="master_8h_source.html#l00211">master.h:211</a></div></div>
<div class="ttc" id="structec__device_html_a969a3e6f0057eeb8b1becc34d500e281"><div class="ttname"><a href="structec__device.html#a969a3e6f0057eeb8b1becc34d500e281">ec_device::tx_bytes</a></div><div class="ttdeci">u64 tx_bytes</div><div class="ttdoc">Number of bytes sent. </div><div class="ttdef"><b>Definition:</b> <a href="device_8h_source.html#l00105">device.h:105</a></div></div>
<div class="ttc" id="device_8c_html_ac74ba2bebd2ed2468ec5b7942555ae9d"><div class="ttname"><a href="device_8c.html#ac74ba2bebd2ed2468ec5b7942555ae9d">ec_device_clear_stats</a></div><div class="ttdeci">void ec_device_clear_stats(ec_device_t *device)</div><div class="ttdoc">Clears the frame statistics. </div><div class="ttdef"><b>Definition:</b> <a href="device_8c_source.html#l00374">device.c:374</a></div></div>
<div class="ttc" id="globals_8h_html_a1e04c301942ee12b54c2caa25d3caab5"><div class="ttname"><a href="globals_8h.html#a1e04c301942ee12b54c2caa25d3caab5">EC_MAX_DATA_SIZE</a></div><div class="ttdeci">#define EC_MAX_DATA_SIZE</div><div class="ttdoc">Resulting maximum data size of a single datagram in a frame. </div><div class="ttdef"><b>Definition:</b> <a href="globals_8h_source.html#l00091">globals.h:91</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_c1346cf4828efdd0d2baf0d391d01b77.html">master</a></li><li class="navelem"><a class="el" href="device_8c.html">device.c</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
